Skip to content

Commit 14dca01

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 0a7b9d3 commit 14dca01

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
@@ -367,7 +367,7 @@ def validate_and_get_data_from_binding_profile(port):
367367
if (constants.OVN_PORT_BINDING_PROFILE not in port or
368368
not validators.is_attr_set(
369369
port[constants.OVN_PORT_BINDING_PROFILE])):
370-
BPInfo({}, None, [])
370+
return BPInfo({}, None, [])
371371
param_set = {}
372372
param_dict = {}
373373
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
@@ -711,6 +711,11 @@ def test_valid_input_surplus_keys(self):
711711
{portbindings.VNIC_TYPE: portbindings.VNIC_DIRECT,
712712
constants.OVN_PORT_BINDING_PROFILE: binding_profile}))
713713

714+
def test_valid_input_no_binding_profile(self):
715+
# Confirm that we treat a port without binding:profile as valid
716+
self.assertEqual(utils.BPInfo({}, None, []),
717+
utils.validate_and_get_data_from_binding_profile({}))
718+
714719
def test_unknown_profile_items_pruned(self):
715720
# Confirm that unknown profile items are pruned
716721
self.assertEqual(

0 commit comments

Comments
 (0)