kolla-docker module can crash with undefined variable

Bug #1819361 reported by Victor Coutellier
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
kolla-ansible
Fix Released
Medium
Victor Coutellier
Queens
Fix Committed
Medium
Mark Goddard
Rocky
Fix Committed
Medium
Mark Goddard
Stein
Fix Released
Medium
Victor Coutellier

Bug Description

It is possible to reference undefined variable in kolla-docker module due to this commit : https://github.com/openstack/kolla-ansible/commit/365bb5177ddc044e567f91c579aa2a85d6592bb9

ansible/library/kolla_docker.py L.974 :
def main():
    module = generate_module()

    try:
        dw = DockerWorker(module)
        result = bool(getattr(dw, module.params.get('action'))())
        module.exit_json(changed=dw.changed, result=result, **dw.result)
    except Exception:
        module.fail_json(changed=True, msg=repr(traceback.format_exc()),
                         **dw.result)

If DockerWorker object initialization fail (mainly if installed docker-py package is broken and we can't init docker client), so we can't reference to dw.result in the except block, and ansible will really crash with a unwanted error message :

UnboundLocalError: local variable 'dw' referenced before assignment

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to kolla-ansible (master)

Reviewed: https://review.openstack.org/642286
Committed: https://git.openstack.org/cgit/openstack/kolla-ansible/commit/?id=3bb4c199817c8aa4ecd4ae684bd28f84933fb14d
Submitter: Zuul
Branch: master

commit 3bb4c199817c8aa4ecd4ae684bd28f84933fb14d
Author: Victor Coutellier <email address hidden>
Date: Sun Mar 10 19:07:00 2019 +0100

    Fix kolla-docker possible undefined variable

    It is possible to reference undefined variable in kolla-docker module if
    DockerWorker object initialization fail, so the current behaviour will
    crash the playbook with the unwanted error message :

    UnboundLocalError: local variable 'dw' referenced before assignment

    Change-Id: Ic8d26b11f93255220888b5406f8ab4a6f81736c2
    Closes-Bug: #1819361

Changed in kolla-ansible:
status: New → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/kolla-ansible 8.0.0.0rc1

This issue was fixed in the openstack/kolla-ansible 8.0.0.0rc1 release candidate.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to kolla-ansible (stable/rocky)

Fix proposed to branch: stable/rocky
Review: https://review.opendev.org/659040

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to kolla-ansible (stable/queens)

Fix proposed to branch: stable/queens
Review: https://review.opendev.org/659041

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to kolla-ansible (stable/rocky)

Reviewed: https://review.opendev.org/659040
Committed: https://git.openstack.org/cgit/openstack/kolla-ansible/commit/?id=ce533592e41950bf6207e8b854e7032983d6f3f8
Submitter: Zuul
Branch: stable/rocky

commit ce533592e41950bf6207e8b854e7032983d6f3f8
Author: Victor Coutellier <email address hidden>
Date: Sun Mar 10 19:07:00 2019 +0100

    Fix kolla-docker possible undefined variable

    It is possible to reference undefined variable in kolla-docker module if
    DockerWorker object initialization fail, so the current behaviour will
    crash the playbook with the unwanted error message :

    UnboundLocalError: local variable 'dw' referenced before assignment

    Change-Id: Ic8d26b11f93255220888b5406f8ab4a6f81736c2
    Closes-Bug: #1819361
    (cherry picked from commit 3bb4c199817c8aa4ecd4ae684bd28f84933fb14d)

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to kolla-ansible (stable/queens)

Reviewed: https://review.opendev.org/659041
Committed: https://git.openstack.org/cgit/openstack/kolla-ansible/commit/?id=15fff23284e9e3140c1af7bf9fc87e5f2b421af8
Submitter: Zuul
Branch: stable/queens

commit 15fff23284e9e3140c1af7bf9fc87e5f2b421af8
Author: Victor Coutellier <email address hidden>
Date: Sun Mar 10 19:07:00 2019 +0100

    Fix kolla-docker possible undefined variable

    It is possible to reference undefined variable in kolla-docker module if
    DockerWorker object initialization fail, so the current behaviour will
    crash the playbook with the unwanted error message :

    UnboundLocalError: local variable 'dw' referenced before assignment

    Change-Id: Ic8d26b11f93255220888b5406f8ab4a6f81736c2
    Closes-Bug: #1819361
    (cherry picked from commit 3bb4c199817c8aa4ecd4ae684bd28f84933fb14d)

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/kolla-ansible 6.2.1

This issue was fixed in the openstack/kolla-ansible 6.2.1 release.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/kolla-ansible 7.1.1

This issue was fixed in the openstack/kolla-ansible 7.1.1 release.

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

Duplicates of this bug

Other bug subscribers

Remote bug watches

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