Merge "Handle creation of Port_Binding with chassis set"

This commit is contained in:
Zuul 2024-01-04 13:21:40 +00:00 committed by Gerrit Code Review
commit 0c251cce60
2 changed files with 19 additions and 6 deletions

View File

@ -159,13 +159,13 @@ class PortBindingChassisCreatedEvent(_PortBindingChassisEvent):
LOG_MSG = 'Port ID %s, datapath %s, OVS port name: %s (event: %s)'
def __init__(self, ovn_agent):
events = (self.ROW_UPDATE,)
events = (self.ROW_CREATE, self.ROW_UPDATE,)
super().__init__(ovn_agent, events)
def match_fn(self, event, row, old):
try:
return (row.chassis[0].name == self.ovn_agent.chassis and
not old.chassis)
(event == self.ROW_CREATE or not old.chassis))
except (IndexError, AttributeError):
return False

View File

@ -118,6 +118,16 @@ class PortBindingEvent(row_event.RowEvent):
self.agent.resync()
class PortBindingCreateWithChassis(PortBindingEvent):
EVENT = PortBindingEvent.ROW_CREATE
def match_fn(self, event, row, old):
self._log_msg = "Port %s in datapath %s bound to our chassis on insert"
if not (super().match_fn(event, row, old) and row.chassis):
return False
return row.chassis[0].name == self.agent.chassis
class PortBindingUpdatedEvent(PortBindingEvent):
EVENT = PortBindingEvent.ROW_UPDATE
@ -387,6 +397,7 @@ class MetadataAgent(object):
tables = ('Encap', 'Port_Binding', 'Datapath_Binding', 'SB_Global',
'Chassis', 'Chassis_Private')
events = (PortBindingUpdatedEvent(self),
PortBindingCreateWithChassis(self),
PortBindingDeletedEvent(self),
SbGlobalUpdateEvent(self),
ChassisPrivateCreateEvent(self),
@ -405,7 +416,8 @@ class MetadataAgent(object):
self._proxy.run()
# Do the initial sync.
self.sync()
# Provisioning handled by PortBindingCreateWithChassis
self.sync(provision=False)
# Register the agent with its corresponding Chassis
self.register_metadata_agent()
@ -456,7 +468,7 @@ class MetadataAgent(object):
return set(p.datapath for p in self._vif_ports(ports))
@_sync_lock
def sync(self):
def sync(self, provision=True):
"""Agent sync.
This function will make sure that all networks with ports in our
@ -483,8 +495,9 @@ class MetadataAgent(object):
# resync all network namespaces based on the associated datapaths,
# even those that are already running. This is to make sure
# everything within each namespace is up to date.
for datapath in net_datapaths:
self.provision_datapath(datapath)
if provision:
for datapath in net_datapaths:
self.provision_datapath(datapath)
@staticmethod
def _get_veth_name(datapath):