Secret generate fail with hostvars is undefined for kubernetes orchestration engine

Bug #1649247 reported by Chung Chih, Hung
22
This bug affects 5 people
Affects Status Importance Assigned to Milestone
kolla-ansible
Fix Released
Critical
Duong Ha-Quang
kolla-kubernetes
Confirmed
Critical
Unassigned

Bug Description

My kolla-ansible and kolla-kubernetes code is upstream.
When I try to generate kubernetes secret, it raise following errors.

> tools/secret-generator.py create
File "tools/secret-generator.py", line 53, in <module>
    nsname = KollaKubernetesResources.GetJinjaDict()[nsname]
  File "/home/lyan/venvs/kolla-kubernetes/local/lib/python2.7/site-packages/kolla_kubernetes/service_resources.py", line 88, in GetJinjaDict
    r = JinjaUtils.dict_self_render(x)
  File "/home/lyan/venvs/kolla-kubernetes/local/lib/python2.7/site-packages/kolla_kubernetes/utils.py", line 181, in dict_self_render
    rendered_template = JinjaUtils.render_jinja(d, template)
  File "/home/lyan/venvs/kolla-kubernetes/local/lib/python2.7/site-packages/kolla_kubernetes/utils.py", line 166, in render_jinja
    rendered_template = j2env.get_template(name).render(dict_)
  File "/home/lyan/venvs/kolla-kubernetes/local/lib/python2.7/site-packages/jinja2/environment.py", line 989, in render
    return self.environment.handle_exception(exc_info, True)
  File "/home/lyan/venvs/kolla-kubernetes/local/lib/python2.7/site-packages/jinja2/environment.py", line 754, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "<template>", line 477, in top-level template code
  File "/home/lyan/venvs/kolla-kubernetes/local/lib/python2.7/site-packages/jinja2/environment.py", line 389, in getitem
    return obj[argument]
jinja2.exceptions.UndefinedError: 'hostvars' is undefined

kolla-kubernetes will found one file named ansible/group_vars/all.yml at kolla directory.
Then try to render the file.
There is one variable named tunnel_interface_addres at kolla-ansible upstream code.

tunnel_interface_address: "{{ hostvars[inventory_hostname]['ansible_' + tunnel_interface]['ipv4']['address'] }}"

This variable will not exist if we using kuberentes orchestration engine.
So there are two solution to fix this issue.

One is override the variable at globals.yml file or kolla-kuberenetes.yml file
The other is add condition statement which will determine whether orchestration engine is ansible at kolla-ansible's code.

I prefer we should add condition statement at kolla-ansible project.
Because of api_interface_address variable also have condition statement to determine whether orchestration engine is using ansible.

Changed in kolla-kubernetes:
assignee: nobody → Chung Chih, Hung (lyanchih)
assignee: Chung Chih, Hung (lyanchih) → nobody
Changed in kolla-ansible:
assignee: nobody → Chung Chih, Hung (lyanchih)
summary: - Secret generate fail with hostvars is undefined
+ Secret generate fail with hostvars is undefined for kubernetes
+ orchestration engine
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to kolla-ansible (master)

Fix proposed to branch: master
Review: https://review.openstack.org/417331

Changed in kolla-ansible:
status: New → In Progress
Steven Dake (sdake)
Changed in kolla-ansible:
milestone: none → ocata-3
importance: Undecided → Critical
Changed in kolla-kubernetes:
status: New → Confirmed
importance: Undecided → Critical
milestone: none → 0.5.0
Changed in kolla-ansible:
milestone: ocata-3 → ocata-rc1
Steven Dake (sdake)
Changed in kolla-kubernetes:
milestone: 0.5.0 → 0.6.0
Duong Ha-Quang (duonghq)
Changed in kolla-ansible:
assignee: Chung Chih, Hung (lyanchih) → Duong Ha-Quang (duonghq)
Changed in kolla-ansible:
milestone: ocata-rc1 → ocata-rc2
milestone: ocata-rc2 → pike-1
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to kolla-ansible (master)

Reviewed: https://review.openstack.org/417331
Committed: https://git.openstack.org/cgit/openstack/kolla-ansible/commit/?id=b719782d4424a0537cea1a40364c10d7d9a9fe80
Submitter: Jenkins
Branch: master

commit b719782d4424a0537cea1a40364c10d7d9a9fe80
Author: Chung Chih, Hung <email address hidden>
Date: Fri Jan 6 17:47:52 2017 +0800

    Secret generate fail with hostvars is undefined

    When Kolla-kubernetes try to generate secret, it will found one file
    named ansible/group_vars/all.yml at kolla reporitory. Then try to render
    the file. There is one variable named tunnel_interface_addres which will
    access hostvars variable, but this variable is not exist at kubernetes
    orchestration engine.

    We should add condition statement which will determine whether
    orchestration engine is ansible.

    Co-Authored-By: Duong Ha-Quang <email address hidden>

    Change-Id: I998a7540de3dcae53acb73de79fb8a8e76cc4225
    Closed-Bug: 1649247

Duong Ha-Quang (duonghq)
Changed in kolla-ansible:
status: In Progress → Fix Released
Steven Dake (sdake)
Changed in kolla-kubernetes:
milestone: 0.6.0 → 0.7.0
Revision history for this message
Surya Prakash Singh (confisurya) wrote :

As per bug description and fix proposed in kolla-ansible. Variable is aslo defined in kolla-k8s repo.
So IMO @lyanchih please check at your end, this is not bug any more.

for reference https://github.com/openstack/kolla-kubernetes/blob/master/ansible/group_vars/all.yml.

Please correct my understanding if I am wrong.

Thanks

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.