Fix service version lookups
There is some cellsv2 code that's conditional upon the nova-api services all being above a specific service version. However the lookup was checking for the 'nova-api' service version which returns the default of 0 because the actual registered service is 'nova-os_compute'. Change-Id: I97a5d8472cc09ae64203de1c91d0db6ec59d83de
This commit is contained in:
parent
f577f650c7
commit
5196b9c90d
|
@ -1606,7 +1606,7 @@ class API(base.Base):
|
||||||
# Before service version 15 deletion of the BuildRequest has no effect
|
# Before service version 15 deletion of the BuildRequest has no effect
|
||||||
# and will be cleaned up as part of the boot process.
|
# and will be cleaned up as part of the boot process.
|
||||||
service_version = objects.Service.get_minimum_version(
|
service_version = objects.Service.get_minimum_version(
|
||||||
context, 'nova-api')
|
context, 'nova-osapi_compute')
|
||||||
if service_version < 15:
|
if service_version < 15:
|
||||||
return False
|
return False
|
||||||
deleted = self._attempt_delete_of_buildrequest(context, instance)
|
deleted = self._attempt_delete_of_buildrequest(context, instance)
|
||||||
|
@ -2143,7 +2143,7 @@ class API(base.Base):
|
||||||
# there is an instance mapping we don't need to honor it for older
|
# there is an instance mapping we don't need to honor it for older
|
||||||
# service versions.
|
# service versions.
|
||||||
service_version = objects.Service.get_minimum_version(
|
service_version = objects.Service.get_minimum_version(
|
||||||
context, 'nova-api')
|
context, 'nova-osapi_compute')
|
||||||
if service_version < 15:
|
if service_version < 15:
|
||||||
return objects.Instance.get_by_uuid(context, instance_uuid,
|
return objects.Instance.get_by_uuid(context, instance_uuid,
|
||||||
expected_attrs=expected_attrs)
|
expected_attrs=expected_attrs)
|
||||||
|
|
|
@ -409,7 +409,7 @@ class ComputeTaskManager(base.Base):
|
||||||
except exception.BuildRequestNotFound:
|
except exception.BuildRequestNotFound:
|
||||||
with excutils.save_and_reraise_exception() as exc_ctxt:
|
with excutils.save_and_reraise_exception() as exc_ctxt:
|
||||||
service_version = objects.Service.get_minimum_version(
|
service_version = objects.Service.get_minimum_version(
|
||||||
context, 'nova-api')
|
context, 'nova-osapi_compute')
|
||||||
if service_version >= 12:
|
if service_version >= 12:
|
||||||
# A BuildRequest was created during the boot process, the
|
# A BuildRequest was created during the boot process, the
|
||||||
# NotFound exception indicates a delete happened which
|
# NotFound exception indicates a delete happened which
|
||||||
|
|
|
@ -1423,13 +1423,17 @@ class _ComputeAPIUnitTestMixIn(object):
|
||||||
inst))
|
inst))
|
||||||
self.assertTrue(build_req_mock.destroy.called)
|
self.assertTrue(build_req_mock.destroy.called)
|
||||||
|
|
||||||
def test_delete_while_booting_low_service_version(self):
|
@mock.patch.object(objects.Service, 'get_minimum_version', return_value=0)
|
||||||
|
def test_delete_while_booting_low_service_version(self,
|
||||||
|
mock_get_service_version):
|
||||||
inst = self._create_instance_obj()
|
inst = self._create_instance_obj()
|
||||||
with mock.patch.object(self.compute_api,
|
with mock.patch.object(self.compute_api,
|
||||||
'_attempt_delete_of_buildrequest') as mock_attempt_delete:
|
'_attempt_delete_of_buildrequest') as mock_attempt_delete:
|
||||||
self.assertFalse(
|
self.assertFalse(
|
||||||
self.compute_api._delete_while_booting(self.context, inst))
|
self.compute_api._delete_while_booting(self.context, inst))
|
||||||
self.assertFalse(mock_attempt_delete.called)
|
self.assertFalse(mock_attempt_delete.called)
|
||||||
|
mock_get_service_version.assert_called_once_with(self.context,
|
||||||
|
'nova-osapi_compute')
|
||||||
|
|
||||||
def test_delete_while_booting_buildreq_not_deleted(self):
|
def test_delete_while_booting_buildreq_not_deleted(self):
|
||||||
self.useFixture(fixtures.AllServicesCurrent())
|
self.useFixture(fixtures.AllServicesCurrent())
|
||||||
|
@ -4101,11 +4105,11 @@ class _ComputeAPIUnitTestMixIn(object):
|
||||||
'security_groups',
|
'security_groups',
|
||||||
'info_cache'])
|
'info_cache'])
|
||||||
|
|
||||||
|
@mock.patch.object(objects.Service, 'get_minimum_version', return_value=15)
|
||||||
@mock.patch.object(objects.InstanceMapping, 'get_by_instance_uuid')
|
@mock.patch.object(objects.InstanceMapping, 'get_by_instance_uuid')
|
||||||
@mock.patch.object(objects.BuildRequest, 'get_by_instance_uuid')
|
@mock.patch.object(objects.BuildRequest, 'get_by_instance_uuid')
|
||||||
def test_get_instance_not_in_cell(self, mock_get_build_req,
|
def test_get_instance_not_in_cell(self, mock_get_build_req,
|
||||||
mock_get_inst_map):
|
mock_get_inst_map, mock_get_min_service):
|
||||||
self.useFixture(fixtures.AllServicesCurrent())
|
|
||||||
build_req_obj = fake_build_request.fake_req_obj(self.context)
|
build_req_obj = fake_build_request.fake_req_obj(self.context)
|
||||||
mock_get_inst_map.return_value = objects.InstanceMapping(
|
mock_get_inst_map.return_value = objects.InstanceMapping(
|
||||||
cell_mapping=None)
|
cell_mapping=None)
|
||||||
|
@ -4116,6 +4120,8 @@ class _ComputeAPIUnitTestMixIn(object):
|
||||||
mock_get_inst_map.assert_called_once_with(self.context, instance.uuid)
|
mock_get_inst_map.assert_called_once_with(self.context, instance.uuid)
|
||||||
mock_get_build_req.assert_called_once_with(self.context, instance.uuid)
|
mock_get_build_req.assert_called_once_with(self.context, instance.uuid)
|
||||||
self.assertEqual(instance, inst_from_build_req)
|
self.assertEqual(instance, inst_from_build_req)
|
||||||
|
mock_get_min_service.assert_called_once_with(self.context,
|
||||||
|
'nova-osapi_compute')
|
||||||
|
|
||||||
@mock.patch.object(context, 'target_cell')
|
@mock.patch.object(context, 'target_cell')
|
||||||
@mock.patch.object(objects.InstanceMapping, 'get_by_instance_uuid')
|
@mock.patch.object(objects.InstanceMapping, 'get_by_instance_uuid')
|
||||||
|
|
|
@ -829,6 +829,7 @@ class _BaseTaskTestCase(object):
|
||||||
|
|
||||||
do_test()
|
do_test()
|
||||||
|
|
||||||
|
@mock.patch.object(objects.Service, 'get_minimum_version', return_value=12)
|
||||||
@mock.patch.object(objects.Instance, 'refresh', new=mock.MagicMock())
|
@mock.patch.object(objects.Instance, 'refresh', new=mock.MagicMock())
|
||||||
@mock.patch.object(objects.BuildRequest, 'get_by_instance_uuid',
|
@mock.patch.object(objects.BuildRequest, 'get_by_instance_uuid',
|
||||||
side_effect=exc.BuildRequestNotFound(uuid='fake'))
|
side_effect=exc.BuildRequestNotFound(uuid='fake'))
|
||||||
|
@ -837,7 +838,7 @@ class _BaseTaskTestCase(object):
|
||||||
@mock.patch.object(conductor_manager.ComputeTaskManager,
|
@mock.patch.object(conductor_manager.ComputeTaskManager,
|
||||||
'_set_vm_state_and_notify', new=mock.MagicMock())
|
'_set_vm_state_and_notify', new=mock.MagicMock())
|
||||||
def test_build_instances_build_request_not_found_because_delete(self,
|
def test_build_instances_build_request_not_found_because_delete(self,
|
||||||
mock_select_dests, mock_build_req_get):
|
mock_select_dests, mock_build_req_get, mock_service_version):
|
||||||
|
|
||||||
mock_select_dests.return_value = [
|
mock_select_dests.return_value = [
|
||||||
{'host': 'host1', 'nodename': 'node1', 'limits': []},
|
{'host': 'host1', 'nodename': 'node1', 'limits': []},
|
||||||
|
@ -850,8 +851,6 @@ class _BaseTaskTestCase(object):
|
||||||
|
|
||||||
# build_instances() is a cast, we need to wait for it to complete
|
# build_instances() is a cast, we need to wait for it to complete
|
||||||
self.useFixture(cast_as_call.CastAsCall(self.stubs))
|
self.useFixture(cast_as_call.CastAsCall(self.stubs))
|
||||||
# Ensure service is high enough to run the new code path
|
|
||||||
self.useFixture(fixtures.AllServicesCurrent())
|
|
||||||
|
|
||||||
inst_map_mock = mock.MagicMock()
|
inst_map_mock = mock.MagicMock()
|
||||||
|
|
||||||
|
@ -875,6 +874,8 @@ class _BaseTaskTestCase(object):
|
||||||
self.assertTrue(inst_map_mock.destroy.called)
|
self.assertTrue(inst_map_mock.destroy.called)
|
||||||
|
|
||||||
do_test()
|
do_test()
|
||||||
|
mock_service_version.assert_called_once_with(self.context,
|
||||||
|
'nova-osapi_compute')
|
||||||
|
|
||||||
def test_unshelve_instance_on_host(self):
|
def test_unshelve_instance_on_host(self):
|
||||||
instance = self._create_fake_instance_obj()
|
instance = self._create_fake_instance_obj()
|
||||||
|
|
Loading…
Reference in New Issue