Merge "Restore retrying the RPC connection to conductor"

This commit is contained in:
Zuul 2020-11-17 14:51:25 +00:00 committed by Gerrit Code Review
commit e20b1f72f3
2 changed files with 19 additions and 3 deletions

View File

@ -249,14 +249,20 @@ class Service(service.Service):
debugger.init()
utils.raise_if_old_compute()
service_obj = cls(host, binary, topic, manager,
report_interval=report_interval,
periodic_enable=periodic_enable,
periodic_fuzzy_delay=periodic_fuzzy_delay,
periodic_interval_max=periodic_interval_max)
# NOTE(gibi): This have to be after the service object creation as
# that is the point where we can safely use the RPC to the conductor.
# E.g. the Service.__init__ actually waits for the conductor to start
# up before it allows the service to be created. The
# raise_if_old_compute() depends on the RPC to be up and does not
# implement its own retry mechanism to connect to the conductor.
utils.raise_if_old_compute()
return service_obj
def kill(self):

View File

@ -268,13 +268,23 @@ class ServiceTestCase(test.NoDBTestCase):
serv.reset()
mock_reset.assert_called_once_with()
@mock.patch('nova.conductor.api.API.wait_until_ready')
@mock.patch('nova.utils.raise_if_old_compute')
def test_old_compute_version_is_checked(self, mock_check_old):
def test_old_compute_version_check_happens_after_wait_for_conductor(
self, mock_check_old, mock_wait):
obj_base.NovaObject.indirection_api = mock.MagicMock()
def fake_wait(*args, **kwargs):
mock_check_old.assert_not_called()
mock_wait.side_effect = fake_wait
service.Service.create(
self.host, self.binary, self.topic,
'nova.tests.unit.test_service.FakeManager')
mock_check_old.assert_called_once_with()
mock_wait.assert_called_once_with(mock.ANY)
class TestWSGIService(test.NoDBTestCase):