From e53115da7fc10381c6f9cedcd909461e3c13c4ea Mon Sep 17 00:00:00 2001 From: Dan Smith Date: Fri, 25 Aug 2017 08:48:49 -0700 Subject: [PATCH] Move hash ring initialization to init_host() for ironic The hash ring initialization code requires calling to conductor over RPC. Nova's service startup initializes the manager and the virt driver, then goes into a polling loop waiting for a conductor to respond to make sure it is ready. Finally, it calls init_host() once things are expected to be working. That is where we should do our initialization that requires conductor to be up. This patch moves the initial refresh into the Ironic driver's init_host() routine. Change-Id: If92f4b1df061f91ffffa7900532a978649efb933 Closes-Bug: #1713095 (cherry picked from commit 361287debf7c2cd5751517cedda8c960c5b5eb66) --- nova/tests/unit/virt/ironic/test_driver.py | 5 ++++- nova/virt/ironic/driver.py | 3 +-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/nova/tests/unit/virt/ironic/test_driver.py b/nova/tests/unit/virt/ironic/test_driver.py index e8f266daf387..e880a41cb6b6 100644 --- a/nova/tests/unit/virt/ironic/test_driver.py +++ b/nova/tests/unit/virt/ironic/test_driver.py @@ -2659,7 +2659,9 @@ class HashRingTestCase(test.NoDBTestCase): @mock.patch.object(ironic_driver.IronicDriver, '_refresh_hash_ring') def test_hash_ring_refreshed_on_init(self, mock_hr): - ironic_driver.IronicDriver(None) + d = ironic_driver.IronicDriver(None) + self.assertFalse(mock_hr.called) + d.init_host('foo') mock_hr.assert_called_once_with(mock.ANY) @mock.patch.object(hash_ring, 'HashRing') @@ -2718,6 +2720,7 @@ class NodeCacheTestCase(test.NoDBTestCase): super(NodeCacheTestCase, self).setUp() self.driver = ironic_driver.IronicDriver(None) + self.driver.init_host('foo') self.driver.virtapi = fake.FakeVirtAPI() self.ctx = nova_context.get_admin_context() diff --git a/nova/virt/ironic/driver.py b/nova/virt/ironic/driver.py index 8f1ad2b28716..a3fd65394cae 100644 --- a/nova/virt/ironic/driver.py +++ b/nova/virt/ironic/driver.py @@ -152,7 +152,6 @@ class IronicDriver(virt_driver.ComputeDriver): self.node_cache = {} self.node_cache_time = 0 self.servicegroup_api = servicegroup.API() - self._refresh_hash_ring(nova_context.get_admin_context()) self.ironicclient = client_wrapper.IronicClientWrapper() @@ -508,7 +507,7 @@ class IronicDriver(virt_driver.ComputeDriver): :param host: the hostname of the compute host. """ - return + self._refresh_hash_ring(nova_context.get_admin_context()) def _pike_flavor_migration(self, node_uuids): """This code is needed in Pike to prevent problems where an operator