Merge "Correct validation for timeout when rolling update"
This commit is contained in:
commit
f6107ce70b
@ -368,14 +368,13 @@ class InstanceGroup(stack_resource.StackResource):
|
||||
efft_bat_sz = min(batch_size, capacity)
|
||||
efft_min_sz = min(min_in_service, capacity)
|
||||
|
||||
batch_cnt = (capacity + efft_bat_sz - 1) // efft_bat_sz
|
||||
if pause_sec * (batch_cnt - 1) >= self.stack.timeout_secs():
|
||||
raise ValueError('The current UpdatePolicy will result '
|
||||
'in stack update timeout.')
|
||||
|
||||
# effective capacity includes temporary capacity added to accommodate
|
||||
# the minimum number of instances in service during update
|
||||
efft_capacity = max(capacity - efft_bat_sz, efft_min_sz) + efft_bat_sz
|
||||
batch_cnt = (efft_capacity + efft_bat_sz - 1) // efft_bat_sz
|
||||
if pause_sec * (batch_cnt - 1) >= self.stack.timeout_secs():
|
||||
raise ValueError('The current UpdatePolicy will result '
|
||||
'in stack update timeout.')
|
||||
|
||||
try:
|
||||
remainder = capacity
|
||||
@ -389,7 +388,8 @@ class InstanceGroup(stack_resource.StackResource):
|
||||
updater.run_to_completion()
|
||||
self.check_update_complete(updater)
|
||||
remainder -= efft_bat_sz
|
||||
if remainder > 0 and pause_sec > 0:
|
||||
if ((remainder > 0 or efft_capacity > capacity) and
|
||||
pause_sec > 0):
|
||||
self._lb_reload()
|
||||
waiter = scheduler.TaskRunner(pause_between_batch)
|
||||
waiter(timeout=pause_sec)
|
||||
|
@ -804,18 +804,23 @@ class AutoScalingGroupTest(common.HeatTestCase):
|
||||
self.m.UnsetStubs()
|
||||
|
||||
# modify the pause time and test for error
|
||||
new_pause_time = 'PT30M'
|
||||
# the following test, effective_capacity is 12
|
||||
# batch_count = (effective_capacity + batch_size -1)//batch_size
|
||||
# = (12 + 2 - 1)//2 = 6
|
||||
# if (batch_count - 1)* pause_time > stack.time_out, to raise error
|
||||
# (6 - 1)*14*60 > 3600, so to raise error
|
||||
new_pause_time = 'PT14M'
|
||||
min_in_service = 10
|
||||
updt_template = json.loads(copy.deepcopy(asg_tmpl_with_updt_policy))
|
||||
group = updt_template['Resources']['WebServerGroup']
|
||||
policy = group['UpdatePolicy']['AutoScalingRollingUpdate']
|
||||
policy['PauseTime'] = new_pause_time
|
||||
policy['MinInstancesInService'] = min_in_service
|
||||
config = updt_template['Resources']['LaunchConfig']
|
||||
config['Properties']['ImageId'] = 'F17-x86_64-cfntools'
|
||||
updated_tmpl = template_format.parse(json.dumps(updt_template))
|
||||
updated_stack = utils.parse_stack(updated_tmpl)
|
||||
self._stub_grp_replace(num_creates_expected_on_updt=0,
|
||||
num_deletes_expected_on_updt=0,
|
||||
num_reloads_expected_on_updt=1)
|
||||
|
||||
self.stub_KeypairConstraint_validate()
|
||||
self.stub_ImageConstraint_validate()
|
||||
self.m.ReplayAll()
|
||||
|
Loading…
Reference in New Issue
Block a user