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. Change-Id: I7fde8ce9dea16679e76b0cb2db1427aeeec0c222 Closes-Bug: #1750618
This commit is contained in:
parent
ea28efda64
commit
a39029076c
nova
@ -2849,23 +2849,14 @@ class ComputeManager(manager.Manager):
|
||||
|
||||
LOG.info("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.
|
||||
rt = self._get_resource_tracker()
|
||||
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.
|
||||
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 = {}
|
||||
|
@ -1230,7 +1230,10 @@ class ServerRebuildTestCase(integrated_helpers._IntegratedTestBase,
|
||||
'/servers/%s/action' % server['id'], rebuild_req_body)
|
||||
self.assertIn('NoValidHost', six.text_type(ex))
|
||||
|
||||
def test_rebuild_with_new_image(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_with_new_image(self, mock_rebuild_claim):
|
||||
"""Rebuilds a server with a different image which will run it through
|
||||
the scheduler to validate the image is still OK with the compute host
|
||||
that the instance is running on.
|
||||
|
Loading…
x
Reference in New Issue
Block a user