Return empty BpInfo if missing binding:profile
https://review.opendev.org/c/openstack/neutron/+/867359 inadvertently dropped a return when binding:profile was missing, making it possible to hit a KeyError when trying to access port["binding:profile"]. This was seen in the Maintenance thread after adding a port. Fixes:b6750fb2b8
Closes-Bug: #2071822 Change-Id: I232daa2905904d464ddf84e66e857f8b1f08e941 (cherry picked from commite5a8829c56
)
This commit is contained in:
parent
c6d4a3e364
commit
346d433aa8
@ -368,7 +368,7 @@ def validate_and_get_data_from_binding_profile(port):
|
|||||||
if (constants.OVN_PORT_BINDING_PROFILE not in port or
|
if (constants.OVN_PORT_BINDING_PROFILE not in port or
|
||||||
not validators.is_attr_set(
|
not validators.is_attr_set(
|
||||||
port[constants.OVN_PORT_BINDING_PROFILE])):
|
port[constants.OVN_PORT_BINDING_PROFILE])):
|
||||||
BPInfo({}, None, [])
|
return BPInfo({}, None, [])
|
||||||
param_set = {}
|
param_set = {}
|
||||||
param_dict = {}
|
param_dict = {}
|
||||||
vnic_type = port.get(portbindings.VNIC_TYPE, portbindings.VNIC_NORMAL)
|
vnic_type = port.get(portbindings.VNIC_TYPE, portbindings.VNIC_NORMAL)
|
||||||
|
@ -756,6 +756,11 @@ class TestValidateAndGetDataFromBindingProfile(base.BaseTestCase):
|
|||||||
{portbindings.VNIC_TYPE: portbindings.VNIC_DIRECT,
|
{portbindings.VNIC_TYPE: portbindings.VNIC_DIRECT,
|
||||||
constants.OVN_PORT_BINDING_PROFILE: binding_profile}))
|
constants.OVN_PORT_BINDING_PROFILE: binding_profile}))
|
||||||
|
|
||||||
|
def test_valid_input_no_binding_profile(self):
|
||||||
|
# Confirm that we treat a port without binding:profile as valid
|
||||||
|
self.assertEqual(utils.BPInfo({}, None, []),
|
||||||
|
utils.validate_and_get_data_from_binding_profile({}))
|
||||||
|
|
||||||
def test_unknown_profile_items_pruned(self):
|
def test_unknown_profile_items_pruned(self):
|
||||||
# Confirm that unknown profile items are pruned
|
# Confirm that unknown profile items are pruned
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
|
Loading…
Reference in New Issue
Block a user