pci_passthrough_whitelist should support single quotes for keys and values

Bug #1470363 reported by Itzik Brown
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Expired
Undecided
Unassigned

Bug Description

When having the following in /etc/nova/nova.conf

pci_passthrough_whitelist={'devname':'enp5s0f1', 'physical_network':'physnet2'}

Nova compute fails to start and I get the error:

2015-07-01 09:48:03.610 4791 ERROR nova.openstack.common.threadgroup [req-b86e5da5-a24e-4eb6-bebd-0ec36fc08021 - - - - -] Invalid PCI devices Whitelist config Invalid entry: '{'devname':'enp5s0f1', 'physical_network':'physnet2'}'
2015-07-01 09:48:03.610 4791 TRACE nova.openstack.common.threadgroup Traceback (most recent call last):
2015-07-01 09:48:03.610 4791 TRACE nova.openstack.common.threadgroup File "/usr/lib/python2.7/site-packages/nova/openstack/common/threadgroup.py", line 145, in wait
2015-07-01 09:48:03.610 4791 TRACE nova.openstack.common.threadgroup x.wait()
2015-07-01 09:48:03.610 4791 TRACE nova.openstack.common.threadgroup File "/usr/lib/python2.7/site-packages/nova/openstack/common/threadgroup.py", line 47, in wait
2015-07-01 09:48:03.610 4791 TRACE nova.openstack.common.threadgroup return self.thread.wait()
2015-07-01 09:48:03.610 4791 TRACE nova.openstack.common.threadgroup File "/usr/lib/python2.7/site-packages/eventlet/greenthread.py", line 175, in wait
2015-07-01 09:48:03.610 4791 TRACE nova.openstack.common.threadgroup return self._exit_event.wait()
2015-07-01 09:48:03.610 4791 TRACE nova.openstack.common.threadgroup File "/usr/lib/python2.7/site-packages/eventlet/event.py", line 121, in wait
2015-07-01 09:48:03.610 4791 TRACE nova.openstack.common.threadgroup return hubs.get_hub().switch()
2015-07-01 09:48:03.610 4791 TRACE nova.openstack.common.threadgroup File "/usr/lib/python2.7/site-packages/eventlet/hubs/hub.py", line 294, in switch
2015-07-01 09:48:03.610 4791 TRACE nova.openstack.common.threadgroup return self.greenlet.switch()
2015-07-01 09:48:03.610 4791 TRACE nova.openstack.common.threadgroup File "/usr/lib/python2.7/site-packages/eventlet/greenthread.py", line 214, in main
2015-07-01 09:48:03.610 4791 TRACE nova.openstack.common.threadgroup result = function(*args, **kwargs)
2015-07-01 09:48:03.610 4791 TRACE nova.openstack.common.threadgroup File "/usr/lib/python2.7/site-packages/nova/openstack/common/service.py", line 497, in run_service
2015-07-01 09:48:03.610 4791 TRACE nova.openstack.common.threadgroup service.start()
2015-07-01 09:48:03.610 4791 TRACE nova.openstack.common.threadgroup File "/usr/lib/python2.7/site-packages/nova/service.py", line 183, in start
2015-07-01 09:48:03.610 4791 TRACE nova.openstack.common.threadgroup self.manager.pre_start_hook()
2015-07-01 09:48:03.610 4791 TRACE nova.openstack.common.threadgroup File "/usr/lib/python2.7/site-packages/nova/compute/manager.py", line 1291, in pre_start_hook
2015-07-01 09:48:03.610 4791 TRACE nova.openstack.common.threadgroup self.update_available_resource(nova.context.get_admin_context())
2015-07-01 09:48:03.610 4791 TRACE nova.openstack.common.threadgroup File "/usr/lib/python2.7/site-packages/nova/compute/manager.py", line 6246, in update_available_resource
2015-07-01 09:48:03.610 4791 TRACE nova.openstack.common.threadgroup rt = self._get_resource_tracker(nodename)
2015-07-01 09:48:03.610 4791 TRACE nova.openstack.common.threadgroup File "/usr/lib/python2.7/site-packages/nova/compute/manager.py", line 715, in _get_resource_tracker
2015-07-01 09:48:03.610 4791 TRACE nova.openstack.common.threadgroup nodename)
2015-07-01 09:48:03.610 4791 TRACE nova.openstack.common.threadgroup File "/usr/lib/python2.7/site-packages/nova/compute/resource_tracker.py", line 78, in __init__
2015-07-01 09:48:03.610 4791 TRACE nova.openstack.common.threadgroup self.pci_filter = pci_whitelist.get_pci_devices_filter()
2015-07-01 09:48:03.610 4791 TRACE nova.openstack.common.threadgroup File "/usr/lib/python2.7/site-packages/nova/pci/whitelist.py", line 109, in get_pci_devices_filter
2015-07-01 09:48:03.610 4791 TRACE nova.openstack.common.threadgroup return PciHostDevicesWhiteList(CONF.pci_passthrough_whitelist)
2015-07-01 09:48:03.610 4791 TRACE nova.openstack.common.threadgroup File "/usr/lib/python2.7/site-packages/nova/pci/whitelist.py", line 89, in __init__
2015-07-01 09:48:03.610 4791 TRACE nova.openstack.common.threadgroup self.specs = self._parse_white_list_from_config(whitelist_spec)
2015-07-01 09:48:03.610 4791 TRACE nova.openstack.common.threadgroup File "/usr/lib/python2.7/site-packages/nova/pci/whitelist.py", line 56, in _parse_white_list_from_config
2015-07-01 09:48:03.610 4791 TRACE nova.openstack.common.threadgroup reason=_("Invalid entry: '%s'") % jsonspec)
2015-07-01 09:48:03.610 4791 TRACE nova.openstack.common.threadgroup PciConfigInvalidWhitelist: Invalid PCI devices Whitelist config Invalid entry: '{'devname':'enp5s0f1', 'physical_network':'physnet2'}'

When using double quotes there is no problem:
pci_passthrough_whitelist={"devname":"enp5s0f1", "physical_network":"physnet2"}

Version
======
python-nova-2015.1.0-13.el7ost.noarch

Tags: config
tags: added: config
Revision history for this message
Markus Zoeller (markus_z) (mzoeller) wrote :

The code tries [1] to parse this config option as a JSON string. Try
this:

    invalid JSON: {'devname':'enp5s0f1', 'physical_network':'physnet2'}
    valid JSON: {"devname":"enp5s0f1", "physical_network":"physnet2"}

with [2]. The config option "pc_alias" behaves the same.

I'm not sure if this is a configuration issue or if the code should
(somehow) tolerate that. At least the documentation of these options [3]
should be clarified that the string option has to be a valid JSON.

[1] https://github.com/openstack/nova/blob/master/nova/pci/whitelist.py
[2] http://jsonlint.com/
[3] http://docs.openstack.org/kilo/config-reference/content/list-of-compute-config-options.html

Changed in nova:
status: New → Confirmed
Moshe Levi (moshele)
Changed in nova:
assignee: nobody → Moshe Levi (moshele)
Changed in nova:
status: Confirmed → In Progress
Revision history for this message
Gary Kotton (garyk) wrote :

My two cents is that we should validate this value on init and if it does not jsonload then we should not start the service

Revision history for this message
Itzik Brown (itzikb1) wrote :

I agree with Gary.

Revision history for this message
Moshe Levi (moshele) wrote :

ok, but that is the current implementation, no ?
I can clarify the error message that to
"Invalid PCI devices Whitelist config Invalid JSON entry: '{'devname':'enp5s0f1', 'physical_network':'physnet2'}'"

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on nova (master)

Change abandoned by Moshe Levi (<email address hidden>) on branch: master
Review: https://review.openstack.org/198535
Reason: should be just documentation update

Moshe Levi (moshele)
Changed in nova:
assignee: Moshe Levi (moshele) → nobody
Changed in nova:
status: In Progress → Confirmed
Revision history for this message
jichenjc (jichenjc) wrote :

from the abandon reason, seems this is incomplete state

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