commands crash when don't have permissions to read config

Bug #1071799 reported by Pádraig Brady
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Medium
Unassigned
oslo.config
Fix Released
Medium
moorryan

Bug Description

In summary running nova-all as a normal user that can't read /etc/nova/nova.conf
will result in a crash. This config file is only readable by 'nova' and 'root' on
Red Hat and Fedora systems for example.
Instead a "permission denied" message should be printed/logged,
rather than a crash and a confusing FileNotFound emitted.
The same is probably true for cinder-all etc.

Here is a a trace of what happens...

[bob@lxbsp2932 ~]$ nova-all
Traceback (most recent call last):
File "/usr/bin/nova-all", line 54, in <module>
flags.parse_args(sys.argv)
File "/usr/lib/python2.6/site-packages/nova/flags.py", line 43, in parse_args
default_config_files=default_config_files)
File "/usr/lib/python2.6/site-packages/nova/openstack/common/cfg.py", line 1026, in __call__
self._parse_config_files()
File "/usr/lib/python2.6/site-packages/nova/openstack/common/cfg.py", line 1496, in _parse_config_files
raise ConfigFilesNotFoundError(not_read_ok)
nova.openstack.common.cfg.ConfigFilesNotFoundError: Failed to read some config files: /etc/nova/nova.conf

Oct 26 16:49:27 lxbsp2932 abrt: detected unhandled Python exception in '/usr/bin/nova-all'
Oct 26 16:49:27 lxbsp2932 abrtd: New client connected
Oct 26 16:49:27 lxbsp2932 abrtd: Directory 'pyhook-2012-10-26-16:49:27-25525' creation detected
Oct 26 16:49:27 lxbsp2932 abrt-server[25530]: Saved Python crash dump of pid 25525 to /var/spool/abrt/pyhook-2012-10-26-16:49:27-25525
Oct 26 16:49:38 lxbsp2932 abrtd: Sending an email...
Oct 26 16:49:38 lxbsp2932 abrtd: Email was sent to: root@localhost
Oct 26 16:49:38 lxbsp2932 abrtd: New problem directory /var/spool/abrt/pyhook-2012-10-26-16:49:27-25525, processin

Michael Still (mikal)
Changed in oslo:
status: New → Triaged
importance: Undecided → Medium
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to oslo-incubator (master)

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

Changed in oslo:
assignee: nobody → Michael Still (mikalstill)
status: Triaged → In Progress
Revision history for this message
Mark McLoughlin (markmc) wrote :

cfg should raise an exception and the caller should catch and print a nice error

Seems like cfg is raising an exception, it's just missing detailed error information (like "permission denied")

Revision history for this message
Mark McLoughlin (markmc) wrote :

Patch was auto-abandoned

Changed in oslo:
status: In Progress → Triaged
assignee: Michael Still (mikalstill) → nobody
Lawrance (jing)
Changed in nova:
assignee: nobody → Lawrance (jing)
Changed in oslo:
assignee: nobody → Lawrance (jing)
Lawrance (jing)
Changed in nova:
assignee: Lawrance (jing) → nobody
Changed in oslo:
assignee: Lawrance (jing) → nobody
affects: oslo-incubator → oslo.config
Changed in oslo.config:
status: Triaged → Confirmed
Revision history for this message
Doug Hellmann (doug-hellmann) wrote :

This bug seems to be reporting the opposite behavior of https://bugs.launchpad.net/oslo.config/+bug/1265737 which claims the error is ignored or not reported and the default settings are used.

Changed in oslo.config:
status: Confirmed → Incomplete
Revision history for this message
moorryan (moorryan) wrote :

Reproduce -
ubuntu@devstack1:/mnt/devstack$ sudo chmod 000 /etc/nova/nova.conf
ubuntu@devstack1:/mnt/devstack$ nova-all
Traceback (most recent call last):
  File "/usr/local/bin/nova-all", line 10, in <module>
    sys.exit(main())
  File "/opt/stack/nova/nova/cmd/all.py", line 49, in main
    config.parse_args(sys.argv)
  File "/opt/stack/nova/nova/config.py", line 40, in parse_args
    default_config_files=default_config_files)
  File "/usr/local/lib/python2.7/dist-packages/oslo/config/cfg.py", line 1683, in __call__
    raise ConfigFilesNotFoundError(self._namespace._files_not_found)
oslo.config.cfg.ConfigFilesNotFoundError: Failed to read some config files: /etc/nova/nova.conf

Changed in oslo.config:
assignee: nobody → moorryan (moorryan)
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/126888

Changed in oslo.config:
status: Incomplete → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to oslo.config (master)

Reviewed: https://review.openstack.org/126888
Committed: https://git.openstack.org/cgit/openstack/oslo.config/commit/?id=41770ad47f263bc88f380f009e8ab2d8c4de150d
Submitter: Jenkins
Branch: master

commit 41770ad47f263bc88f380f009e8ab2d8c4de150d
Author: Ryan Moore <email address hidden>
Date: Wed Oct 8 13:19:43 2014 +0100

    Report permission denied when parsing config

    Previously was returning ConfigFilesNotFoundError, when
    underlying error was 13 - Permission Denied

    Change-Id: I2c418f023c510205aa12a3acb9b09e6b1681f0d4
    Closes-Bug: #1071799

Changed in oslo.config:
status: In Progress → Fix Committed
Changed in oslo.config:
milestone: none → 1.5.0
status: Fix Committed → Fix Released
Revision history for this message
Davanum Srinivas (DIMS) (dims-v) wrote :

fixed in oslo

Changed in nova:
status: Confirmed → Fix Committed
Thierry Carrez (ttx)
Changed in nova:
milestone: none → kilo-3
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in nova:
milestone: kilo-3 → 2015.1.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.