Browse Source

Add wait event for metadataagent sb_idl

resolve bug:'MetadataAgent' object has no attribute 'sb_idl'

(cherry picked from Neutron 385b0ad203da40a2c0110948c0f46feb78ead2be)

Closes-Bug: #1953295
Change-Id: Id83bee82e5c476395ff422dcaf89c0095e74a8ec
changes/53/823853/1
Lucas Alvares Gomes 5 months ago
parent
commit
57d27d6e21
  1. 17
      networking_ovn/agent/metadata/agent.py

17
networking_ovn/agent/metadata/agent.py

@ -14,6 +14,7 @@
import collections
import re
import threading
from neutron.agent.linux import external_process
from neutron.agent.linux import ip_lib
@ -203,6 +204,18 @@ class MetadataAgent(object):
self._process_monitor = external_process.ProcessMonitor(
config=self.conf,
resource_type='metadata')
self._sb_idl = None
self._post_fork_event = threading.Event()
@property
def sb_idl(self):
if not self._sb_idl:
self._post_fork_event.wait()
return self._sb_idl
@sb_idl.setter
def sb_idl(self, val):
self._sb_idl = val
def _load_config(self):
self.chassis = self._get_own_chassis_name()
@ -240,6 +253,7 @@ class MetadataAgent(object):
# Chassis table.
# Open the connection to OVN SB database.
self.has_chassis_private = False
self._post_fork_event.clear()
try:
self.sb_idl = ovsdb.MetadataAgentOvnSbIdl(
chassis=self.chassis, tables=tables + ('Chassis_Private', ),
@ -250,6 +264,9 @@ class MetadataAgent(object):
chassis=self.chassis, tables=tables,
events=events + (ChassisCreateEvent(self), )).start()
# Now IDL connections can be safely used.
self._post_fork_event.set()
# Do the initial sync.
self.sync()

Loading…
Cancel
Save