Fix TypeError in prep_resize allocation cleanup

The CachingScheduler doesn't create allocations in
placement so when prep_resize fails and it tries
to revert allocations, the _revert_allocation() method
returns False and then prep_resize calls
delete_allocation_for_failed_resize() which since change
I7891b98f225f97ad47f189afb9110ef31c810717 has taken a
context argument, but that's not being passed so it
results in a TypeError.

This fixes the TypeError and adds a functional test case
which runs a resize reschedule scenario with the
CachingScheduler.

Change-Id: I0ec0c2d3f7ef8d2274b97a28a175d53921edc9db
Closes-Bug: #1781100
(cherry picked from commit 78af1de158)
This commit is contained in:
Matt Riedemann 2018-07-10 22:11:05 -04:00
parent 7ae2dc840a
commit 246c61d82b
2 changed files with 10 additions and 1 deletions

View File

@ -4142,7 +4142,7 @@ class ComputeManager(manager.Manager):
# FIXME(danms): Remove this in Rocky
rt = self._get_resource_tracker()
rt.delete_allocation_for_failed_resize(
instance, node, instance_type)
context, instance, node, instance_type)
# try to re-schedule the resize elsewhere:
exc_info = sys.exc_info()
self._reschedule_resize_or_reraise(context, image, instance,

View File

@ -78,3 +78,12 @@ class TestServerResizeReschedule(ProviderUsageBaseTestCase):
'VERIFY_RESIZE')
self.assertEqual(self.flavor2['name'],
server['flavor']['original_name'])
class TestServerResizeRescheduleWithCachingScheduler(
TestServerResizeReschedule):
"""Tests the reschedule scenario using the CachingScheduler."""
def setUp(self):
self.flags(driver='caching_scheduler', group='scheduler')
super(TestServerResizeRescheduleWithCachingScheduler, self).setUp()