Allows writing to config objects but the data is not consistent internally

Bug #1586192 reported by Sean Perry
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
oslo.config
Triaged
Low
Unassigned

Bug Description

Use case:

     self.conf(['--blaa-foo', 'bar'])

     self.conf.blaa.foo == 'bar' # true
     self.conf['blaa']['foo'] == 'bar' # true

     self.conf.blaa.foo = 'new_value'
     self.conf.blaa.foo == 'new_value # true
     self.conf['blaa']['foo'] == 'new_value' # false!

The `__getattr__` call returns a GroupAttr object for `blaa`. When I write to `foo` that creates a member variable on `blaa`. Now, when `__getitem__` is called it does not check for an attribute on `blaa` but instead goes back to the `__cache`.

Either:

a) Writes are not permitted and `__setattr__` should be used to block them
b) Writes are ok and `__getitem__` should check `hasattr` before calling `_get`.

We came across this in a Keystone Middleware test.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to oslo.config (master)

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

Changed in oslo.config:
assignee: nobody → Sean Perry (sean-perry-a)
status: New → In Progress
Changed in oslo.config:
assignee: Sean Perry (sean-perry-a) → Alexis Lee (alexisl)
Revision history for this message
Haifeng.Yan (yanheven) wrote :

if want to override some opt, can use conf.set_override() instead.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on oslo.config (master)

Change abandoned by ChangBo Guo(gcb) (<email address hidden>) on branch: master
Review: https://review.openstack.org/321889
Reason: This is no update more than 6 months, feel free to restore it if you want to continue work on this.

Revision history for this message
Doug Hellmann (doug-hellmann) wrote :

We should make the configuration object write-only (at least for defined configuration values).

Changed in oslo.config:
status: In Progress → Triaged
importance: Undecided → Low
assignee: Alexis Lee (alexisl) → nobody
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.