Skip to content

Commit 346d433

Browse files
otherwiseguyralonsoh
authored andcommitted
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: b6750fb Closes-Bug: #2071822 Change-Id: I232daa2905904d464ddf84e66e857f8b1f08e941 (cherry picked from commit e5a8829)
1 parent c6d4a3e commit 346d433

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

neutron/common/ovn/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ def validate_and_get_data_from_binding_profile(port):
368368
if (constants.OVN_PORT_BINDING_PROFILE not in port or
369369
not validators.is_attr_set(
370370
port[constants.OVN_PORT_BINDING_PROFILE])):
371-
BPInfo({}, None, [])
371+
return BPInfo({}, None, [])
372372
param_set = {}
373373
param_dict = {}
374374
vnic_type = port.get(portbindings.VNIC_TYPE, portbindings.VNIC_NORMAL)

neutron/tests/unit/common/ovn/test_utils.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,11 @@ def test_valid_input_surplus_keys(self):
756756
{portbindings.VNIC_TYPE: portbindings.VNIC_DIRECT,
757757
constants.OVN_PORT_BINDING_PROFILE: binding_profile}))
758758

759+
def test_valid_input_no_binding_profile(self):
760+
# Confirm that we treat a port without binding:profile as valid
761+
self.assertEqual(utils.BPInfo({}, None, []),
762+
utils.validate_and_get_data_from_binding_profile({}))
763+
759764
def test_unknown_profile_items_pruned(self):
760765
# Confirm that unknown profile items are pruned
761766
self.assertEqual(

0 commit comments

Comments
 (0)