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
This commit is contained in:
Dan Smith 2017-08-25 08:48:49 -07:00
parent 1080506f16
commit 361287debf
2 changed files with 5 additions and 3 deletions

View File

@ -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()

View File

@ -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()
@ -512,7 +511,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