_is_opt_registered does identity check

Bug #999307 reported by Joshua Harlow
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Low
Giampaolo Lauria
openstack-common
Fix Released
Wishlist
Giampaolo Lauria

Bug Description

When using _is_opt_registered (of cfg) it seems like there is a identity check that happens here instead of an equality check.

In glance, it was suggested to define the options inside a function, and then register the opt when that function is entered, this of course makes the opt registration blow up, since the option will not be "identically" the same (due to a previous function call occurring with a different opt, that is equivalent but not identical).

This also will happen if opts are defined inside classes (ie anywhere not globally) and that class is constructed twice or a function that defines them is called twice (thus causing duplication option errors).

Possible this line:

if opts[opt.dest]['opt'] is not opt:

Should use equality (or check on the names??)

Revision history for this message
Mark McLoughlin (markmc) wrote :

This was intentional to avoid registering different option schemas under the same name

Use cases are:

  opt = StrOpt('foo')

  def do_something():
      CONF.register_opt(opt)
      print CONF.foo

or

  class Bar:

      opt = StrOpt('foo')

      def __init__(self):
          CONF.register_opt(opt)

      def do_something(self):
          print CONF.foo

However, I'd take a patch to add an equality check, but all fields need to be checked, not just the name

Changed in openstack-common:
importance: Undecided → Wishlist
Revision history for this message
Joshua Harlow (harlowja) wrote :

Will do, let me work on that.

Changed in openstack-common:
assignee: nobody → Giampaolo Lauria (lauria)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to openstack-common (master)

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

Changed in openstack-common:
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to openstack-common (master)

Reviewed: https://review.openstack.org/10081
Committed: http://github.com/openstack/openstack-common/commit/90da88cce51bccd320e89141ed7384d2e7ccca9d
Submitter: Jenkins
Branch: master

commit 90da88cce51bccd320e89141ed7384d2e7ccca9d
Author: Giampaolo Lauria <email address hidden>
Date: Fri Jul 20 16:41:45 2012 -0400

    Modifies _is_opt_registered fcn to check for duplicate opts

    This change fixes bug 999307

    Currently, the check for duplicate options is done by checking
    whether they are the same object. The proposed fix is to check whether
    all the object fields have the same value.

    Change-Id: I2b72d630a0c8821df1d81e25d316d8d9195be492

Changed in openstack-common:
status: In Progress → Fix Committed
Sean Dague (sdague)
Changed in nova:
importance: Undecided → Low
Changed in nova:
assignee: nobody → Giampaolo Lauria (lauria)
status: New → In Progress
Mark McLoughlin (markmc)
Changed in openstack-common:
milestone: none → 2012.2
status: Fix Committed → Fix Released
Changed in nova:
status: In Progress → 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.