diff options
author | Zuul <zuul@review.opendev.org> | 2020-04-17 09:34:07 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2020-04-17 09:34:07 +0000 |
commit | 6db7e8bf68c6c955567a1f174357ea44758cd944 (patch) | |
tree | 9d7ccaa1eb142d24c1896b615f91ee50eb8d3c00 /ironic | |
parent | 19547cc989df1500c732a538233080f724c4c432 (diff) | |
parent | 861f35b038431f64dbc29c64a230461efa41b60e (diff) | |
download | ironic-6db7e8bf68c6c955567a1f174357ea44758cd944.tar.gz |
Merge "Release reservation when stoping the ironic-conductor service"
Diffstat (limited to 'ironic')
-rw-r--r-- | ironic/conductor/base_manager.py | 2 | ||||
-rw-r--r-- | ironic/tests/unit/conductor/test_base_manager.py | 11 |
2 files changed, 13 insertions, 0 deletions
diff --git a/ironic/conductor/base_manager.py b/ironic/conductor/base_manager.py index c5c7d4b90..cd63d875c 100644 --- a/ironic/conductor/base_manager.py +++ b/ironic/conductor/base_manager.py @@ -297,6 +297,8 @@ class BaseConductorManager(object): return self._shutdown = True self._keepalive_evt.set() + # clear all locks held by this conductor before deregistering + self.dbapi.clear_node_reservations_for_conductor(self.host) if deregister: try: # Inform the cluster that this conductor is shutting down. diff --git a/ironic/tests/unit/conductor/test_base_manager.py b/ironic/tests/unit/conductor/test_base_manager.py index f8ba77c3f..49cacbff5 100644 --- a/ironic/tests/unit/conductor/test_base_manager.py +++ b/ironic/tests/unit/conductor/test_base_manager.py @@ -64,6 +64,17 @@ class StartStopTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase): node.refresh() self.assertIsNone(node.reservation) + def test_stop_clears_conductor_locks(self): + node = obj_utils.create_test_node(self.context, + reservation=self.hostname) + node.save() + self._start_service() + res = objects.Conductor.get_by_hostname(self.context, self.hostname) + self.assertEqual(self.hostname, res['hostname']) + self.service.del_host() + node.refresh() + self.assertIsNone(node.reservation) + def test_stop_unregisters_conductor(self): self._start_service() res = objects.Conductor.get_by_hostname(self.context, self.hostname) |