a05ef30fb9
This is a follow up to [1] to make the API behave consistently by always asynchronously casting to conductor during resize and cold migration regardless of same-cell or cross-cell migration. From the end user point of view, not much changes besides the possibility of some exceptions occurring during scheduling which would have resulted in a 400 BadRequest error. The user still gets a 202 response, must poll the server status until the server goes to VERIFY_RESIZE status or times out, and can check the instance actions if the resize/migrate fails. The specific errors that can occur are not really an API contract and as such end user applications should not be building logic around, for example, getting a NoValidHost error. It should be noted, however, that by default non-admin users cannot see the instance action event traceback that would contain the error, e.g. NoValidHost. The only exception types removed from handling in the API are (1) AllocationMoveFailed which can be raised when the conductor MigrationTask runs replace_allocation_with_migration and (2) NoValidHost when the scheduler is called to select destinations. Because of this, quite a few functional negative tests have to be adjusted since the API no longer returns a 400 for NoValidHost and other errors that can happen during scheduling. Finally, the do_cast kwarg is left on the conductor API method since the compute service calls it during same-cell reschedule as a synchronous RPC call and has error handling if rescheduling in conductor fails. [1] I098f91d8c498e5a85266e193ad37c08aca4792b2 Change-Id: I711e56bcb4b72605253fa63be230a68e03e45b84
130 lines
5.9 KiB
Python
130 lines
5.9 KiB
Python
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
# not use this file except in compliance with the License. You may obtain
|
|
# a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
# License for the specific language governing permissions and limitations
|
|
# under the License.
|
|
|
|
from nova.tests import fixtures
|
|
from nova.tests.functional.notification_sample_tests \
|
|
import notification_sample_base
|
|
from nova.tests.unit import fake_notifier
|
|
|
|
|
|
class TestComputeTaskNotificationSample(
|
|
notification_sample_base.NotificationSampleTestBase):
|
|
|
|
def setUp(self):
|
|
self.flags(use_neutron=True)
|
|
super(TestComputeTaskNotificationSample, self).setUp()
|
|
self.neutron = fixtures.NeutronFixture(self)
|
|
self.useFixture(self.neutron)
|
|
|
|
def test_build_instances_fault(self):
|
|
# Force down the compute node
|
|
service_id = self.api.get_service_id('nova-compute')
|
|
self.admin_api.put_service_force_down(service_id, True)
|
|
|
|
server = self._boot_a_server(
|
|
expected_status='ERROR',
|
|
extra_params={'networks': [{'port': self.neutron.port_1['id']}]},
|
|
additional_extra_specs={'hw:numa_nodes': 1,
|
|
'hw:numa_cpus.0': '0',
|
|
'hw:numa_mem.0': 512})
|
|
self._wait_for_notification('compute_task.build_instances.error')
|
|
# 0. scheduler.select_destinations.start
|
|
# 1. compute_task.rebuild_server.error
|
|
self.assertEqual(2, len(fake_notifier.VERSIONED_NOTIFICATIONS),
|
|
fake_notifier.VERSIONED_NOTIFICATIONS)
|
|
self._verify_notification(
|
|
'compute_task-build_instances-error',
|
|
replacements={
|
|
'instance_uuid': server['id'],
|
|
'request_spec.instance_uuid': server['id'],
|
|
'request_spec.security_groups': [],
|
|
'request_spec.numa_topology.instance_uuid': server['id'],
|
|
'request_spec.pci_requests.instance_uuid': server['id'],
|
|
'reason.function_name': self.ANY,
|
|
'reason.module_name': self.ANY,
|
|
'reason.traceback': self.ANY
|
|
},
|
|
actual=fake_notifier.VERSIONED_NOTIFICATIONS[1])
|
|
|
|
def test_rebuild_fault(self):
|
|
server = self._boot_a_server(
|
|
extra_params={'networks': [{'port': self.neutron.port_1['id']}]},
|
|
additional_extra_specs={'hw:numa_nodes': 1,
|
|
'hw:numa_cpus.0': '0',
|
|
'hw:numa_mem.0': 512})
|
|
self._wait_for_notification('instance.create.end')
|
|
# Force down the compute node
|
|
service_id = self.api.get_service_id('nova-compute')
|
|
self.admin_api.put_service_force_down(service_id, True)
|
|
|
|
fake_notifier.reset()
|
|
|
|
# NOTE(takashin): The rebuild action and the evacuate action shares
|
|
# same code path. So the 'evacuate' action is used for this test.
|
|
post = {'evacuate': {}}
|
|
|
|
self.admin_api.post_server_action(server['id'], post)
|
|
self._wait_for_notification('compute_task.rebuild_server.error')
|
|
# 0. instance.evacuate
|
|
# 1. scheduler.select_destinations.start
|
|
# 2. compute_task.rebuild_server.error
|
|
self.assertEqual(3, len(fake_notifier.VERSIONED_NOTIFICATIONS),
|
|
fake_notifier.VERSIONED_NOTIFICATIONS)
|
|
self._verify_notification(
|
|
'compute_task-rebuild_server-error',
|
|
replacements={
|
|
'instance_uuid': server['id'],
|
|
'request_spec.instance_uuid': server['id'],
|
|
'request_spec.security_groups': [],
|
|
'request_spec.numa_topology.instance_uuid': server['id'],
|
|
'request_spec.pci_requests.instance_uuid': server['id'],
|
|
'reason.function_name': self.ANY,
|
|
'reason.module_name': self.ANY,
|
|
'reason.traceback': self.ANY
|
|
},
|
|
actual=fake_notifier.VERSIONED_NOTIFICATIONS[2])
|
|
|
|
def test_migrate_fault(self):
|
|
server = self._boot_a_server(
|
|
extra_params={'networks': [{'port': self.neutron.port_1['id']}]},
|
|
additional_extra_specs={'hw:numa_nodes': 1,
|
|
'hw:numa_cpus.0': '0',
|
|
'hw:numa_mem.0': 512})
|
|
self._wait_for_notification('instance.create.end')
|
|
# Force down the compute node
|
|
service_id = self.api.get_service_id('nova-compute')
|
|
self.admin_api.put_service_force_down(service_id, True)
|
|
|
|
fake_notifier.reset()
|
|
|
|
# Note that the operation will return a 202 response but fail with
|
|
# NoValidHost asynchronously.
|
|
self.admin_api.post_server_action(server['id'], {'migrate': None})
|
|
self._wait_for_notification('compute_task.migrate_server.error')
|
|
# 0. scheduler.select_destinations.start
|
|
# 1. compute_task.migrate_server.error
|
|
self.assertEqual(2, len(fake_notifier.VERSIONED_NOTIFICATIONS),
|
|
fake_notifier.VERSIONED_NOTIFICATIONS)
|
|
self._verify_notification(
|
|
'compute_task-migrate_server-error',
|
|
replacements={
|
|
'instance_uuid': server['id'],
|
|
'request_spec.instance_uuid': server['id'],
|
|
'request_spec.security_groups': [],
|
|
'request_spec.numa_topology.instance_uuid': server['id'],
|
|
'request_spec.pci_requests.instance_uuid': server['id'],
|
|
'reason.function_name': self.ANY,
|
|
'reason.module_name': self.ANY,
|
|
'reason.traceback': self.ANY
|
|
},
|
|
actual=fake_notifier.VERSIONED_NOTIFICATIONS[1])
|