Use variable before assignment in update_consistencygroup

Bug #1645207 reported by Lisa Li
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Cinder
Fix Released
Low
Unassigned

Bug Description

tIn The following codes, variable add_vol_ref is used before it is assigned.

https://github.com/openstack/cinder/blob/master/cinder/volume/manager.py#L3202

https://github.com/openstack/cinder/blob/master/cinder/volume/manager.py#L3231

                add_vol_ref = self.db.volume_get(context, add_vol)
            except exception.VolumeNotFound:
                LOG.error(_LE("Update consistency group "
                              "failed to add volume-%(volume_id)s: "
                              "VolumeNotFound."),
                          {'volume_id': add_vol_ref['id']},

When the volume is not found, it gives following error message:

UnboundLocalError: local variable 'remove_vol_ref' referenced before assignment

Lisa Li (lisali)
Changed in cinder:
importance: Undecided → Low
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix proposed to cinder (master)

Related fix proposed to branch: master
Review: https://review.openstack.org/403525

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix merged to cinder (master)

Reviewed: https://review.openstack.org/403525
Committed: https://git.openstack.org/cgit/openstack/cinder/commit/?id=57d257f14904e27b2aeb38c030882e2984467a22
Submitter: Jenkins
Branch: master

commit 57d257f14904e27b2aeb38c030882e2984467a22
Author: lisali <email address hidden>
Date: Mon Nov 28 07:00:13 2016 +0000

    Fix UnBoundLocalError in update_consistencygroup

    The existed codes use variables before assignement in
    update_consistencygroup. This patch is to fix the problem.

    Change-Id: If74d23b9413209ee8db3c58fc71d215abeb580b2
    Related-Bug: 1645207

Revision history for this message
Sean McGinnis (sean-mcginnis) wrote : Bug Assignee Expired

Unassigning due to no activity for > 6 months.

Changed in cinder:
assignee: Lisa Li (lisali) → nobody
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix proposed to cinder (master)

Related fix proposed to branch: master
Review: https://review.openstack.org/608914

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix merged to cinder (master)

Reviewed: https://review.openstack.org/608914
Committed: https://git.openstack.org/cgit/openstack/cinder/commit/?id=2ec51c3912691c9918ccf45ec42930ea00536b70
Submitter: Zuul
Branch: master

commit 2ec51c3912691c9918ccf45ec42930ea00536b70
Author: whoami-rajat <email address hidden>
Date: Tue Oct 9 16:13:03 2018 +0530

    Fix: UnboundLocalError variable referenced before assignment

    The variable used inside the try block is also used in the except
    block for logging volume id which errors out to
    UnboundLocalError: local variable 'add_vol_ref' referenced before
    assignment.
    This patch addresses the issue by using the volume id from the
    for loop.

    Change-Id: Ia43a6f2df7fd4066a0ed26450b26a1456d4cecfa
    Related-Bug: #1645207

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix proposed to cinder (master)

Related fix proposed to branch: master
Review: https://review.openstack.org/610476

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix merged to cinder (master)

Reviewed: https://review.openstack.org/610476
Committed: https://git.openstack.org/cgit/openstack/cinder/commit/?id=6449d734c788b5e30b5f11d9911b4b729d31b28d
Submitter: Zuul
Branch: master

commit 6449d734c788b5e30b5f11d9911b4b729d31b28d
Author: whoami-rajat <email address hidden>
Date: Mon Oct 15 16:27:15 2018 +0530

    Adding regression test for update_group

    Initially the issue was fixed here If74d23b9413209ee8db3c58fc71d215abeb580b2,
    but due to code changes, the same issue was repeated and fixed here,
    Ia43a6f2df7fd4066a0ed26450b26a1456d4cecfa.
    Addressing the comment on the latest fix, adding test case.

    Change-Id: I03d6214abf050e5f9a2cc5fa0772150bbbf8520e
    Related-Bug: #1645207

Eric Harney (eharney)
Changed in cinder:
status: New → Fix Released
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.