Restore retrying the RPC connection to conductor

Before Ie15ec8299ae52ae8f5334d591ed3944e9585cf71 if the compute was
started before the conductor then the compute retried the connection
until the conductor was up. The Ie15ec8299ae52ae8f5334d591ed3944e9585cf71
break this behavior as the service version check runs before this RPC
retry mechanism and therefore the compute simply fails to start without
a retry if no conductor is started.

This patch moves the service version check after the RPC connection
retry mechanism.

Change-Id: Iad0ba1a02868eebc2f43b1ac843fcc5096cd5c47
Closes-Bug: #1904181
This commit is contained in:
Balazs Gibizer 2020-11-13 11:47:51 +01:00
parent eb279e9a56
commit 433bee58bc
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):