Only attempt a rebuild claim for an evacuation to a new host
Change I11746d1ea996a0f18b7c54b4c9c21df58cc4714b changed the behavior of the API and conductor when rebuilding an instance with a new image such that the image is run through the scheduler filters again to see if it will work on the existing host that the instance is running on. As a result, conductor started passing 'scheduled_node' to the compute which was using it for logic to tell if a claim should be attempted. We don't need to do a claim for a rebuild since we're on the same host. This removes the scheduled_node logic from the claim code, as we should only ever attempt a claim if we're evacuating, which we can determine based on the 'recreate' parameter. Conflicts: nova/tests/functional/test_servers.py NOTE(mriedem): test_rebuild_with_new_image does not exist in Ocata and does not apply to Ocata since it is primarily testing allocations getting created in Placement via the FilterScheduler, which was new in Pike. As a result the change to that test is not part of this backport, but a similar assertion is added to an existing rebuild unit test. Change-Id: I7fde8ce9dea16679e76b0cb2db1427aeeec0c222 Closes-Bug: #1750618 (cherry picked from commita39029076c
) (cherry picked from commit3c5e519a88
) (cherry picked from commit9890f3f696
)
This commit is contained in:
parent
c45efbdfe2
commit
286dd2c23c
|
@ -2722,23 +2722,14 @@ class ComputeManager(manager.Manager):
|
|||
|
||||
LOG.info(_LI("Rebuilding instance"), instance=instance)
|
||||
|
||||
# NOTE(gyee): there are three possible scenarios.
|
||||
#
|
||||
# 1. instance is being rebuilt on the same node. In this case,
|
||||
# recreate should be False and scheduled_node should be None.
|
||||
# 2. instance is being rebuilt on a node chosen by the
|
||||
# scheduler (i.e. evacuate). In this case, scheduled_node should
|
||||
# be specified and recreate should be True.
|
||||
# 3. instance is being rebuilt on a node chosen by the user. (i.e.
|
||||
# force evacuate). In this case, scheduled_node is not specified
|
||||
# and recreate is set to True.
|
||||
#
|
||||
# For scenarios #2 and #3, we must do rebuild claim as server is
|
||||
# being evacuated to a different node.
|
||||
if recreate or scheduled_node is not None:
|
||||
if recreate:
|
||||
# This is an evacuation to a new host, so we need to perform a
|
||||
# resource claim.
|
||||
rt = self._get_resource_tracker()
|
||||
rebuild_claim = rt.rebuild_claim
|
||||
else:
|
||||
# This is a rebuild to the same host, so we don't need to make
|
||||
# a claim since the instance is already on this host.
|
||||
rebuild_claim = claims.NopClaim
|
||||
|
||||
image_meta = {}
|
||||
|
|
|
@ -3022,7 +3022,11 @@ class ComputeManagerUnitTestCase(test.NoDBTestCase):
|
|||
ex = exception.InstanceNotFound(instance_id=instance.uuid)
|
||||
self._test_rebuild_ex(instance, ex)
|
||||
|
||||
def test_rebuild_node_not_updated_if_not_recreate(self):
|
||||
# A rebuild to the same host should never attempt a rebuild claim.
|
||||
@mock.patch('nova.compute.resource_tracker.ResourceTracker.rebuild_claim',
|
||||
new_callable=mock.NonCallableMock)
|
||||
def test_rebuild_node_not_updated_if_not_recreate(self,
|
||||
mock_rebuild_claim):
|
||||
node = uuidutils.generate_uuid() # ironic node uuid
|
||||
instance = fake_instance.fake_instance_obj(self.context, node=node)
|
||||
instance.migration_context = None
|
||||
|
|
Loading…
Reference in New Issue