Numerous config options ignored due to CONF used in import context

Bug #1354403 reported by Matthew Booth
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Expired
Low
Unassigned

Bug Description

In general[1] it is incorrect to use the value of a config variable at import time, because although the config variable may have been registered, its value will not have been loaded. The result will always be the default value, regardless of the contents of the relevant config file.

I did a quick scan of Nova, and found the following instances of config variables being used in import context:

nova/api/openstack/common.py:limited()
nova/api/openstack/common.py:get_limit_and_marker()
nova/compute/manager.py:_heal_instance_info_cache()
nova/compute/manager.py:_poll_shelved_instances()
nova/compute/manager.py:_poll_bandwidth_usage()
nova/compute/manager.py:_poll_volume_usage()
nova/compute/manager.py:_sync_power_states()
nova/compute/manager.py:_cleanup_running_deleted_instances()
nova/compute/manager.py:_run_image_cache_manager_pass()
nova/compute/manager.py:_run_pending_deletes()
nova/network/manager.py:_periodic_update_dns()
nova/scheduler/manager.py:_run_periodic_tasks()

Consequently, it appears that the given values of the following config variables are being ignored:

osapi_max_limit
heal_instance_info_cache_interval
shelved_poll_interval
bandwidth_poll_interval
volume_usage_poll_interval
sync_power_state_interval
running_deleted_instance_poll_interval
image_cache_manager_interval
instance_delete_interval
dns_update_periodic_interval
scheduler_driver_task_period

[1] This doesn't apply to drivers, which are loaded dynamically after the config has been loaded. However, relying on that seems even nastier.

Tags: config oslo
Tracy Jones (tjones-i)
tags: added: compute oslo scheduler
Revision history for this message
Sean Dague (sdague) wrote :

This seems like somethign that should get addressed sooner rather than later

Changed in nova:
status: New → Confirmed
importance: Undecided → High
Boden R (boden)
Changed in nova:
assignee: nobody → Boden R (boden)
Boden R (boden)
Changed in nova:
status: Confirmed → In Progress
Revision history for this message
Boden R (boden) wrote :

All of the CONF usages outlined in the bug description are in fact referenced after the configuration is loaded and therefore all conf values are honored -- there is no functional deficiency here.

However as noted this is bad practice and we likely need a better way to handle these cases.

Lowing importance based on my statements above.

Boden R (boden)
Changed in nova:
importance: High → Medium
Revision history for this message
Boden R (boden) wrote :

Moving to low based on https://wiki.openstack.org/wiki/BugTriage there are no functional deficiencies here. Removing myself as the assignee as there are more important bugs to address right now.

Changed in nova:
importance: Medium → Low
assignee: Boden R (boden) → nobody
Changed in nova:
status: In Progress → Confirmed
Revision history for this message
Ganesh (ganeshna) wrote :

I would like to work on this bug. Can someone please give a correct expected usage example for the config values, so that I can start making the changes ?

Changed in nova:
assignee: nobody → Stephen Finucane (sfinucan)
no longer affects: oslo.service
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (master)

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

Changed in nova:
status: Confirmed → In Progress
Revision history for this message
Stephen Finucane (stephenfinucane) wrote :

Some more information:

A variable used as a function parameter results becomes immutable: changes to the variable after the function has been registered do not get reflected in the function definition. For example:

    >>> class Config(object):
    ... x = 5
    >>> config = Config()
    >>>
    >>> def func(param=config.x):
    ... print(param)
    >>> func()
    5
    >>> config.x = 9
    >>> func()
    5

Currently, this mistake when configuration settings are passed as arguments to functions and decorators. Should these settings change, the updated values will not be reflected in the functions/decorators. However, this is not an issue for methods or constructors as these are only evaluated when an instance of a class is created. Correct this oversight by ensuring these settings are set at runtime in affected functions.

tags: added: config
tags: removed: compute scheduler
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (master)

Reviewed: https://review.openstack.org/241361
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=a9716c880e4dd6ff2e8e6a15405d90d1402c816e
Submitter: Jenkins
Branch: master

commit a9716c880e4dd6ff2e8e6a15405d90d1402c816e
Author: Stephen Finucane <email address hidden>
Date: Tue Nov 3 17:18:02 2015 +0000

    Rework 'limited' and 'get_limit_and_marker'

    The 'max_limit' parameter in each of these functions are only used
    in one test. Remove these. In addition, make consistent use of the
    other helper functions within these functions.

    Partial-bug: #1354403
    Change-Id: Ifab24647396a868bde123623e39bbba3bd501dfa

Revision history for this message
Stephen Finucane (stephenfinucane) wrote :

I have some of this done but there is yet more to do

Changed in nova:
assignee: Stephen Finucane (stephenfinucane) → nobody
Revision history for this message
Maciej Szankin (mszankin) wrote :

Tagging as New. It is old and requires to be verified.

Changed in nova:
status: In Progress → New
Revision history for this message
Sean Dague (sdague) wrote :

If anyone is interested in keeping this bug alive, can they provide a script that can be run on the Nova code to ensure that we know when it's done?

Changed in nova:
status: New → Incomplete
Revision history for this message
Launchpad Janitor (janitor) wrote :

[Expired for OpenStack Compute (nova) because there has been no activity for 60 days.]

Changed in nova:
status: Incomplete → Expired
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.