summaryrefslogtreecommitdiff
path: root/ironic
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2020-04-17 09:34:07 +0000
committerGerrit Code Review <review@openstack.org>2020-04-17 09:34:07 +0000
commit6db7e8bf68c6c955567a1f174357ea44758cd944 (patch)
tree9d7ccaa1eb142d24c1896b615f91ee50eb8d3c00 /ironic
parent19547cc989df1500c732a538233080f724c4c432 (diff)
parent861f35b038431f64dbc29c64a230461efa41b60e (diff)
downloadironic-6db7e8bf68c6c955567a1f174357ea44758cd944.tar.gz
Merge "Release reservation when stoping the ironic-conductor service"
Diffstat (limited to 'ironic')
-rw-r--r--ironic/conductor/base_manager.py2
-rw-r--r--ironic/tests/unit/conductor/test_base_manager.py11
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)