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
This commit is contained in:
@@ -159,6 +159,8 @@ class HaproxyConfiguratorBase(object):
|
|||||||
|
|
||||||
|
|
||||||
class MetadataDriverBase(object, metaclass=abc.ABCMeta):
|
class MetadataDriverBase(object, metaclass=abc.ABCMeta):
|
||||||
|
monitors = {}
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def haproxy_configurator():
|
def haproxy_configurator():
|
||||||
@@ -253,6 +255,8 @@ class MetadataDriverBase(object, metaclass=abc.ABCMeta):
|
|||||||
return
|
return
|
||||||
monitor.register(uuid, METADATA_SERVICE_NAME, pm)
|
monitor.register(uuid, METADATA_SERVICE_NAME, pm)
|
||||||
|
|
||||||
|
cls.monitors[uuid] = pm
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def destroy_monitored_metadata_proxy(cls, monitor, uuid, conf, ns_name):
|
def destroy_monitored_metadata_proxy(cls, monitor, uuid, conf, ns_name):
|
||||||
monitor.unregister(uuid, METADATA_SERVICE_NAME)
|
monitor.unregister(uuid, METADATA_SERVICE_NAME)
|
||||||
@@ -272,6 +276,8 @@ class MetadataDriverBase(object, metaclass=abc.ABCMeta):
|
|||||||
configurator = cls.haproxy_configurator()
|
configurator = cls.haproxy_configurator()
|
||||||
configurator.cleanup_config_file(uuid, cfg.CONF.state_path)
|
configurator.cleanup_config_file(uuid, cfg.CONF.state_path)
|
||||||
|
|
||||||
|
cls.monitors.pop(uuid, None)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _get_metadata_proxy_process_manager(cls, router_id, conf, ns_name=None,
|
def _get_metadata_proxy_process_manager(cls, router_id, conf, ns_name=None,
|
||||||
callback=None):
|
callback=None):
|
||||||
|
|||||||
@@ -312,6 +312,7 @@ class TestMetadataDriverProcess(base.BaseTestCase):
|
|||||||
network_id=network_id)
|
network_id=network_id)
|
||||||
error_log.assert_called_once()
|
error_log.assert_called_once()
|
||||||
process_monitor.register.assert_not_called()
|
process_monitor.register.assert_not_called()
|
||||||
|
self.assertNotIn(network_id, metadata_driver.MetadataDriver.monitors)
|
||||||
|
|
||||||
def test_create_config_file_wrong_user(self):
|
def test_create_config_file_wrong_user(self):
|
||||||
with mock.patch('pwd.getpwnam', side_effect=KeyError):
|
with mock.patch('pwd.getpwnam', side_effect=KeyError):
|
||||||
|
|||||||
@@ -197,6 +197,7 @@ class TestMetadataDriverProcess(base.BaseTestCase):
|
|||||||
|
|
||||||
error_log.assert_called_once()
|
error_log.assert_called_once()
|
||||||
process_monitor.register.assert_not_called()
|
process_monitor.register.assert_not_called()
|
||||||
|
self.assertNotIn(network_id, metadata_driver.MetadataDriver.monitors)
|
||||||
|
|
||||||
def test_create_config_file_wrong_user(self):
|
def test_create_config_file_wrong_user(self):
|
||||||
with mock.patch('pwd.getpwnam', side_effect=KeyError):
|
with mock.patch('pwd.getpwnam', side_effect=KeyError):
|
||||||
|
|||||||
Reference in New Issue
Block a user