oslo_config.cfg.ConfigFilesPermissionDeniedError: Failed to open some config files: /etc/neutron/neutron.conf

Bug #1442543 reported by Ihar Hrachyshka
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
neutron
Fix Released
Undecided
Ihar Hrachyshka
Kilo
New
Undecided
Unassigned

Bug Description

When running lbaas unit tests on a system where neutron.conf is installed into /etc/neutron, and if the file does not have read permissions for the user running unit tests, I get the following error:

{0} neutron_lbaas.tests.unit.services.loadbalancer.agent.test_agent.TestLbaasService.test_main [0.113960s] ... FAILED

Captured traceback:
~~~~~~~~~~~~~~~~~~~
    Traceback (most recent call last):
      File "neutron_lbaas/tests/unit/services/loadbalancer/agent/test_agent.py", line 45, in test_main
        agent.main()
      File "neutron_lbaas/services/loadbalancer/agent/agent.py", line 58, in main
        common_config.init(sys.argv[1:]){0} neutron_lbaas.tests.unit.services.loadbalancer.agent.test_agent.TestLbaasService.test_main [0.113960s] ... FAILED

Captured traceback:
~~~~~~~~~~~~~~~~~~~
    Traceback (most recent call last):
      File "neutron_lbaas/tests/unit/services/loadbalancer/agent/test_agent.py", line 45, in test_main
        agent.main()
      File "neutron_lbaas/services/loadbalancer/agent/agent.py", line 58, in main
        common_config.init(sys.argv[1:])
      File "/home/ihrachyshka/proj/openstack/neutron-lbaas/.tox/py27/src/neutron/neutron/common/config.py", line 185, in init
        **kwargs)
      File "/home/ihrachyshka/proj/openstack/neutron-lbaas/.tox/py27/lib/python2.7/site-packages/oslo_config/cfg.py", line 1856, in __call__
        self._namespace._files_permission_denied)
    oslo_config.cfg.ConfigFilesPermissionDeniedError: Failed to open some config files: /etc/neutron/neutron.conf

      File "/home/ihrachyshka/proj/openstack/neutron-lbaas/.tox/py27/src/neutron/neutron/common/config.py", line 185, in init
        **kwargs)
      File "/home/ihrachyshka/proj/openstack/neutron-lbaas/.tox/py27/lib/python2.7/site-packages/oslo_config/cfg.py", line 1856, in __call__
        self._namespace._files_permission_denied)
    oslo_config.cfg.ConfigFilesPermissionDeniedError: Failed to open some config files: /etc/neutron/neutron.conf

This is because oslo.config tries to autodiscover config files, and read them, in case they exist. Unit tests should be isolated from those files.

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

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

Changed in neutron:
assignee: nobody → Ihar Hrachyshka (ihar-hrachyshka)
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (master)

Reviewed: https://review.openstack.org/172354
Committed: https://git.openstack.org/cgit/openstack/neutron/commit/?id=54fc39308277d4aedc3e399286714d719ecacfbb
Submitter: Jenkins
Branch: master

commit 54fc39308277d4aedc3e399286714d719ecacfbb
Author: Ihar Hrachyshka <email address hidden>
Date: Fri Apr 10 11:29:56 2015 +0200

    tests: don't allow oslo.config to autodiscover config files

    oslo.config makes attempts to autodiscover configuration files using
    find_config_files() helper. If e.g. /etc/neutron/neutron.conf exists,
    and is not readable, the following test failure can be experienced:

    oslo_config.cfg.ConfigFilesPermissionDeniedError: Failed to open some
    config files: /etc/neutron/neutron.conf

    Unit tests must not rely on any external state of the system and run
    successfully no matter whether neutron is actually installed on the
    system, or not.

    Closes-Bug: #1442543
    Change-Id: Ic90d8c40b2072fdda152703b84081719936b5f4e

Changed in neutron:
status: In Progress → Fix Committed
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to neutron (neutron-pecan)

Fix proposed to branch: neutron-pecan
Review: https://review.openstack.org/185072

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to neutron (stable/kilo)

Fix proposed to branch: stable/kilo
Review: https://review.openstack.org/189324

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (stable/kilo)

Reviewed: https://review.openstack.org/189324
Committed: https://git.openstack.org/cgit/openstack/neutron/commit/?id=415adbf4a2272e09fbd809b37819a21bdedf6861
Submitter: Jenkins
Branch: stable/kilo

commit 415adbf4a2272e09fbd809b37819a21bdedf6861
Author: Ihar Hrachyshka <email address hidden>
Date: Fri Apr 10 11:29:56 2015 +0200

    tests: don't allow oslo.config to autodiscover config files

    oslo.config makes attempts to autodiscover configuration files using
    find_config_files() helper. If e.g. /etc/neutron/neutron.conf exists,
    and is not readable, the following test failure can be experienced:

    oslo_config.cfg.ConfigFilesPermissionDeniedError: Failed to open some
    config files: /etc/neutron/neutron.conf

    Unit tests must not rely on any external state of the system and run
    successfully no matter whether neutron is actually installed on the
    system, or not.

    Closes-Bug: #1442543
    Change-Id: Ic90d8c40b2072fdda152703b84081719936b5f4e
    (cherry picked from commit 54fc39308277d4aedc3e399286714d719ecacfbb)

tags: added: in-stable-kilo
Thierry Carrez (ttx)
Changed in neutron:
milestone: none → liberty-1
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in neutron:
milestone: liberty-1 → 7.0.0
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.