Fix version cap when no nova-compute started
When a zero service version is returned, it means that we have no services running for the requested binary. In that case, we should assume the latest version available until told otherwise. This usually happens in first-start cases, where everything is likely to be up to date anyway. This change addresses an issue where the version returned had been hard-coded to 4.11 (mitaka). Change-Id: I696a8ea8adbe9481e11407ecafd5e47b2bd29804 Closes-bug: 1753443
This commit is contained in:
parent
a6edacd66c
commit
b81a66b3b0
@ -381,17 +381,19 @@ class ComputeAPI(object):
|
||||
service_version = objects.Service.get_minimum_version(
|
||||
context.get_admin_context(), 'nova-compute')
|
||||
|
||||
history = service_obj.SERVICE_VERSION_HISTORY
|
||||
|
||||
# NOTE(johngarbutt) when there are no nova-compute services running we
|
||||
# get service_version == 0. In that case we do not want to cache
|
||||
# this result, because we will get a better answer next time.
|
||||
# As a sane default, return the version from the last release.
|
||||
# As a sane default, return the current version.
|
||||
if service_version == 0:
|
||||
LOG.debug("Not caching compute RPC version_cap, because min "
|
||||
"service_version is 0. Please ensure a nova-compute "
|
||||
"service has been started. Defaulting to Mitaka RPC.")
|
||||
return self.VERSION_ALIASES["mitaka"]
|
||||
"service has been started. Defaulting to current "
|
||||
"version.")
|
||||
return history[service_obj.SERVICE_VERSION]['compute_rpc']
|
||||
|
||||
history = service_obj.SERVICE_VERSION_HISTORY
|
||||
try:
|
||||
version_cap = history[service_version]['compute_rpc']
|
||||
except IndexError:
|
||||
|
@ -25,6 +25,7 @@ from nova import context
|
||||
from nova import exception
|
||||
from nova.objects import block_device as objects_block_dev
|
||||
from nova.objects import migration as migration_obj
|
||||
from nova.objects import service as service_obj
|
||||
from nova import test
|
||||
from nova.tests.unit import fake_block_device
|
||||
from nova.tests.unit import fake_flavor
|
||||
@ -91,7 +92,9 @@ class ComputeRpcAPITestCase(test.NoDBTestCase):
|
||||
self.flags(compute='auto', group='upgrade_levels')
|
||||
compute_rpcapi.LAST_VERSION = None
|
||||
rpcapi = compute_rpcapi.ComputeAPI()
|
||||
self.assertEqual('4.11', rpcapi.router.version_cap)
|
||||
history = service_obj.SERVICE_VERSION_HISTORY
|
||||
current_version = history[service_obj.SERVICE_VERSION]['compute_rpc']
|
||||
self.assertEqual(current_version, rpcapi.router.version_cap)
|
||||
mock_get_min.assert_called_once_with(mock.ANY, 'nova-compute')
|
||||
self.assertIsNone(compute_rpcapi.LAST_VERSION)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user