Merge "Correct validation for timeout when rolling update"

This commit is contained in:
Jenkins 2014-11-20 04:28:50 +00:00 committed by Gerrit Code Review
commit f6107ce70b
2 changed files with 15 additions and 10 deletions

View File

@ -368,14 +368,13 @@ class InstanceGroup(stack_resource.StackResource):
efft_bat_sz = min(batch_size, capacity) efft_bat_sz = min(batch_size, capacity)
efft_min_sz = min(min_in_service, 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 # effective capacity includes temporary capacity added to accommodate
# the minimum number of instances in service during update # the minimum number of instances in service during update
efft_capacity = max(capacity - efft_bat_sz, efft_min_sz) + efft_bat_sz 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: try:
remainder = capacity remainder = capacity
@ -389,7 +388,8 @@ class InstanceGroup(stack_resource.StackResource):
updater.run_to_completion() updater.run_to_completion()
self.check_update_complete(updater) self.check_update_complete(updater)
remainder -= efft_bat_sz 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() self._lb_reload()
waiter = scheduler.TaskRunner(pause_between_batch) waiter = scheduler.TaskRunner(pause_between_batch)
waiter(timeout=pause_sec) waiter(timeout=pause_sec)

View File

@ -804,18 +804,23 @@ class AutoScalingGroupTest(common.HeatTestCase):
self.m.UnsetStubs() self.m.UnsetStubs()
# modify the pause time and test for error # 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)) updt_template = json.loads(copy.deepcopy(asg_tmpl_with_updt_policy))
group = updt_template['Resources']['WebServerGroup'] group = updt_template['Resources']['WebServerGroup']
policy = group['UpdatePolicy']['AutoScalingRollingUpdate'] policy = group['UpdatePolicy']['AutoScalingRollingUpdate']
policy['PauseTime'] = new_pause_time policy['PauseTime'] = new_pause_time
policy['MinInstancesInService'] = min_in_service
config = updt_template['Resources']['LaunchConfig'] config = updt_template['Resources']['LaunchConfig']
config['Properties']['ImageId'] = 'F17-x86_64-cfntools' config['Properties']['ImageId'] = 'F17-x86_64-cfntools'
updated_tmpl = template_format.parse(json.dumps(updt_template)) updated_tmpl = template_format.parse(json.dumps(updt_template))
updated_stack = utils.parse_stack(updated_tmpl) 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_KeypairConstraint_validate()
self.stub_ImageConstraint_validate() self.stub_ImageConstraint_validate()
self.m.ReplayAll() self.m.ReplayAll()