add more waiting to instance type change

Amazon changes instance type immediately and returns when instance
in 'stooped' state. But our code can return when instance in
'resized' state and then can't start it. So this patchset adds some
waiting after confirm_resize to ensure that instance in right state.

Change-Id: I6ddeace63a3c448281ec17d1788c1eb22c594116
This commit is contained in:
Andrey Pavlov 2015-08-16 09:59:52 +03:00
parent f5b320edbb
commit 2e10e834fb
1 changed files with 7 additions and 1 deletions

View File

@ -686,7 +686,7 @@ def _modify_instance_type(context, instance, instance_type):
# 1. current code returns HTTP 500 code if time is out. client retries
# query. code can detect that resizing in progress and wait again.
# 2. make this operation async by some way...
for dummy in xrange(60):
for dummy in xrange(45):
os_instance = nova.servers.get(os_instance)
vm_state = getattr(os_instance, 'OS-EXT-STS:vm_state')
if vm_state == vm_states_RESIZED:
@ -698,6 +698,12 @@ def _modify_instance_type(context, instance, instance_type):
raise exception.EC2APIException(
message=_('Time is out for instance resizing'))
os_instance.confirm_resize()
for dummy in xrange(15):
os_instance = nova.servers.get(os_instance)
vm_state = getattr(os_instance, 'OS-EXT-STS:vm_state')
if vm_state != vm_states_RESIZED:
break
time.sleep(1)
def reset_instance_attribute(context, instance_id, attribute):