Skip to content

Commit a61598f

Browse files
committed
Put monitors dictionary back in MetadataDriverBase class
When the common Metadata Driver was created in [0], the monitors dictionary was dropped accidentally. This causes tracebacks in the fullstack L3-HA tests when after_router_updated() is called. Put it back along with its related tests. [0] https://review.opendev.org/c/openstack/neutron/+/894399 Closes-bug: #2065145 Change-Id: I137ed7cec9e0eafdb3a351e5a414f5a0c16f33e5 (cherry picked from commit 5b62e27)
1 parent ac1472c commit a61598f

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

neutron/agent/metadata/driver_base.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,8 @@ def cleanup_config_file(cls, uuid, state_path):
159159

160160

161161
class MetadataDriverBase(object, metaclass=abc.ABCMeta):
162+
monitors = {}
163+
162164
@staticmethod
163165
@abc.abstractmethod
164166
def haproxy_configurator():
@@ -253,6 +255,8 @@ def spawn_monitored_metadata_proxy(cls, monitor, ns_name, port, conf,
253255
return
254256
monitor.register(uuid, METADATA_SERVICE_NAME, pm)
255257

258+
cls.monitors[uuid] = pm
259+
256260
@classmethod
257261
def destroy_monitored_metadata_proxy(cls, monitor, uuid, conf, ns_name):
258262
monitor.unregister(uuid, METADATA_SERVICE_NAME)
@@ -272,6 +276,8 @@ def destroy_monitored_metadata_proxy(cls, monitor, uuid, conf, ns_name):
272276
configurator = cls.haproxy_configurator()
273277
configurator.cleanup_config_file(uuid, cfg.CONF.state_path)
274278

279+
cls.monitors.pop(uuid, None)
280+
275281
@classmethod
276282
def _get_metadata_proxy_process_manager(cls, router_id, conf, ns_name=None,
277283
callback=None):

neutron/tests/unit/agent/metadata/test_driver.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,7 @@ def test_spawn_metadata_proxy_handles_process_exception(self, error_log):
312312
network_id=network_id)
313313
error_log.assert_called_once()
314314
process_monitor.register.assert_not_called()
315+
self.assertNotIn(network_id, metadata_driver.MetadataDriver.monitors)
315316

316317
def test_create_config_file_wrong_user(self):
317318
with mock.patch('pwd.getpwnam', side_effect=KeyError):

neutron/tests/unit/agent/ovn/metadata/test_driver.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ def test_spawn_metadata_proxy_handles_process_exception(self, error_log):
197197

198198
error_log.assert_called_once()
199199
process_monitor.register.assert_not_called()
200+
self.assertNotIn(network_id, metadata_driver.MetadataDriver.monitors)
200201

201202
def test_create_config_file_wrong_user(self):
202203
with mock.patch('pwd.getpwnam', side_effect=KeyError):

0 commit comments

Comments
 (0)