CONF.set_override doesn't alias deprecated opts

Bug #1709728 reported by Eric Fried
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
oslo.config
Won't Fix
Undecided
Unassigned

Bug Description

If I deprecate opt 'bad' in favor of opt 'good', I can still use a conf file that sets 'bad', and CONF.good will show up in my code with that value.

However, when I CONF.set_override('bad', ...), the override value shows up in CONF.bad, but not in CONF.good.

Example:

=============================
from oslo_config import cfg
from oslo_log import log

log.logging.basicConfig(level='DEBUG')

goodopt = cfg.StrOpt('good')
badopt = cfg.StrOpt('bad')
goodopt.deprecated_opts = [cfg.DeprecatedOpt('bad')]

cfg.CONF.register_opts([goodopt, badopt])

cfg.CONF()
print('good: %s' % cfg.CONF.good)
print('bad: %s' % cfg.CONF.bad)
cfg.CONF.set_override('bad', 'bar')
print('good: %s' % cfg.CONF.good)
print('bad: %s' % cfg.CONF.bad)
=============================

With conf file:

=============================
[DEFAULT]
bad = foo
=============================

Actual output:
=============================
WARNING:oslo_config.cfg:Option "bad" from group "DEFAULT" is deprecated. Use option "good" from group "DEFAULT".
good: foo
bad: foo
good: foo
bad: bar
=============================

Expected output:
=============================
WARNING:oslo_config.cfg:Option "bad" from group "DEFAULT" is deprecated. Use option "good" from group "DEFAULT".
good: foo
bad: foo
good: bar
bad: bar
=============================

Revision history for this message
ChangBo Guo(gcb) (glongwave) wrote :

Usually set_override is used in tests. I suggest use CONF.good in code, just leave CONF.bad for operators.

Changed in oslo.config:
status: New → Confirmed
Revision history for this message
Eric Fried (efried) wrote :

@gcb - Yes, sorry I didn't mention that this only affects test. I hit it when trying to write this one: https://review.openstack.org/#/c/492247/6/nova/tests/unit/cmd/test_status.py@148

Thanks!

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

When bad is deprecated, it should no longer be registered at all.

And gcb is right, the test code should be updated when an application deprecates an option.

Changed in oslo.config:
status: Confirmed → Won't Fix
Revision history for this message
Eric Fried (efried) wrote :

I won't fight this, but I'd like to clarify/restate the effect of the bug:

I can't write unit test code confirming that the deprecated opt still works.

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.