← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 2081009] [NEW] oslo_config.cfg.NotInitializedError when switching default policy_file in oslo.policy

 

Public bug reported:

While we attempted to update the default policy file in
https://review.opendev.org/c/openstack/oslo.policy/+/929714 , we
observed the glance-api can't start and complains the error below.

```
Traceback (most recent call last):
  File "/opt/stack/data/venv/bin/glance-wsgi-api", line 6, in <module>
    from glance.common.wsgi_app import init_app
  File "/opt/stack/glance/glance/common/wsgi_app.py", line 24, in <module>
    from glance.common import config
  File "/opt/stack/glance/glance/common/config.py", line 643, in <module>
    policy.Enforcer(CONF)
  File "/opt/stack/oslo.policy/oslo_policy/policy.py", line 543, in __init__
    self.policy_file = policy_file or pick_default_policy_file(
  File "/opt/stack/oslo.policy/oslo_policy/policy.py", line 378, in pick_default_policy_file
    if conf.find_file(conf.oslo_policy.policy_file):
  File "/opt/stack/data/venv/lib/python3.10/site-packages/oslo_config/cfg.py", line 2782, in find_file
Traceback (most recent call last):
  File "/opt/stack/data/venv/bin/glance-wsgi-api", line 6, in <module>
    from glance.common.wsgi_app import init_app
  File "/opt/stack/glance/glance/common/wsgi_app.py", line 24, in <module>
    from glance.common import config
  File "/opt/stack/glance/glance/common/config.py", line 643, in <module>
    policy.Enforcer(CONF)
  File "/opt/stack/oslo.policy/oslo_policy/policy.py", line 543, in __init__
    self.policy_file = policy_file or pick_default_policy_file(
  File "/opt/stack/oslo.policy/oslo_policy/policy.py", line 378, in pick_default_policy_file
    raise NotInitializedError()
oslo_config.cfg.NotInitializedError: call expression on parser has not been invoked
```

The problem here is that Enforcer() is called directly at the module
level in glance.common.config and we can't guarantee the module is
imported after CONF instance is initialized.

** Affects: glance
     Importance: Undecided
         Status: In Progress

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to Glance.
https://bugs.launchpad.net/bugs/2081009

Title:
  oslo_config.cfg.NotInitializedError when switching default policy_file
  in oslo.policy

Status in Glance:
  In Progress

Bug description:
  While we attempted to update the default policy file in
  https://review.opendev.org/c/openstack/oslo.policy/+/929714 , we
  observed the glance-api can't start and complains the error below.

  ```
  Traceback (most recent call last):
    File "/opt/stack/data/venv/bin/glance-wsgi-api", line 6, in <module>
      from glance.common.wsgi_app import init_app
    File "/opt/stack/glance/glance/common/wsgi_app.py", line 24, in <module>
      from glance.common import config
    File "/opt/stack/glance/glance/common/config.py", line 643, in <module>
      policy.Enforcer(CONF)
    File "/opt/stack/oslo.policy/oslo_policy/policy.py", line 543, in __init__
      self.policy_file = policy_file or pick_default_policy_file(
    File "/opt/stack/oslo.policy/oslo_policy/policy.py", line 378, in pick_default_policy_file
      if conf.find_file(conf.oslo_policy.policy_file):
    File "/opt/stack/data/venv/lib/python3.10/site-packages/oslo_config/cfg.py", line 2782, in find_file
  Traceback (most recent call last):
    File "/opt/stack/data/venv/bin/glance-wsgi-api", line 6, in <module>
      from glance.common.wsgi_app import init_app
    File "/opt/stack/glance/glance/common/wsgi_app.py", line 24, in <module>
      from glance.common import config
    File "/opt/stack/glance/glance/common/config.py", line 643, in <module>
      policy.Enforcer(CONF)
    File "/opt/stack/oslo.policy/oslo_policy/policy.py", line 543, in __init__
      self.policy_file = policy_file or pick_default_policy_file(
    File "/opt/stack/oslo.policy/oslo_policy/policy.py", line 378, in pick_default_policy_file
      raise NotInitializedError()
  oslo_config.cfg.NotInitializedError: call expression on parser has not been invoked
  ```

  The problem here is that Enforcer() is called directly at the module
  level in glance.common.config and we can't guarantee the module is
  imported after CONF instance is initialized.

To manage notifications about this bug go to:
https://bugs.launchpad.net/glance/+bug/2081009/+subscriptions