diff --git a/nova/conductor/tasks/migrate.py b/nova/conductor/tasks/migrate.py index d0b09f8e7963..db342b4139f1 100644 --- a/nova/conductor/tasks/migrate.py +++ b/nova/conductor/tasks/migrate.py @@ -281,6 +281,13 @@ class MigrationTask(base.TaskBase): raise exception.MaxRetriesExceeded(reason=reason) def _execute(self): + # NOTE(sbauza): Force_hosts/nodes needs to be reset if we want to make + # sure that the next destination is not forced to be the original host. + # This needs to be done before the populate_retry call otherwise + # retries will be disabled if the server was created with a forced + # host/node. + self.request_spec.reset_forced_destinations() + # TODO(sbauza): Remove once all the scheduler.utils methods accept a # RequestSpec object in the signature. legacy_props = self.request_spec.to_legacy_filter_properties_dict() @@ -293,11 +300,6 @@ class MigrationTask(base.TaskBase): scheduler_utils.populate_retry(legacy_props, self.instance.uuid) - # NOTE(sbauza): Force_hosts/nodes needs to be reset - # if we want to make sure that the next destination - # is not forced to be the original host - self.request_spec.reset_forced_destinations() - port_res_req = self.network_api.get_requested_resource_for_instance( self.context, self.instance.uuid) # NOTE(gibi): When cyborg or other module wants to handle similar diff --git a/nova/tests/functional/regressions/test_bug_1845291.py b/nova/tests/functional/regressions/test_bug_1845291.py index 8a2a30e795b7..382971b5fc29 100644 --- a/nova/tests/functional/regressions/test_bug_1845291.py +++ b/nova/tests/functional/regressions/test_bug_1845291.py @@ -68,20 +68,11 @@ class ForcedHostMissingReScheduleTestCase( # We expect that the instance re-scheduled but successfully ended # up on the second destination host. - # FIXME(gibi): this is bug 1845291 as nova does not try to - # re-schedule. The forced host was not cleared from the - # RequestSpec before the MigrationTask populated the retry - # information for the re-scheduling. - # self._wait_for_server_parameter( - # self.api, server, - # { - # 'OS-EXT-STS:task_state': None, - # 'status': 'VERIFY_RESIZE'}) - # Instead the server goes to ERROR state self._wait_for_server_parameter( - self.api, server, {'status': 'ERROR'}) + self.api, server, + { + 'OS-EXT-STS:task_state': None, + 'status': 'VERIFY_RESIZE'}) # we ensure that there was a failed and then a successful claim call - # FIXME(gibi): this is bug 1845291 as there was no second claim call - # self.assertEqual(2, len(claim_calls)) - self.assertEqual(1, len(claim_calls)) + self.assertEqual(2, len(claim_calls))