Make sure UpdatePolicy is unset for Heat scaling group
It is defined within the properties as rolling_updates. This patch is to make it more obvious to users that UpdatePolicy is not supported. Change-Id: I8162d27036843d0b9282cd8f4aa4d2eb93afba19 Closes-bug: 1423426
This commit is contained in:
parent
d56778dc7a
commit
d84c9bc0a6
|
@ -123,6 +123,7 @@ class AutoScalingResourceGroup(aws_asg.AutoScalingGroup):
|
|||
_("The current size of AutoscalingResourceGroup.")
|
||||
),
|
||||
}
|
||||
update_policy_schema = {}
|
||||
|
||||
def _get_instance_definition(self):
|
||||
rsrc = self.properties[self.RESOURCE]
|
||||
|
|
|
@ -135,10 +135,11 @@ class InstanceGroup(stack_resource.StackResource):
|
|||
"""
|
||||
super(InstanceGroup, self).validate()
|
||||
|
||||
if self.update_policy:
|
||||
if self.update_policy is not None:
|
||||
self.update_policy.validate()
|
||||
policy_name = self.update_policy_schema.keys()[0]
|
||||
if self.update_policy[policy_name]:
|
||||
policy_name = self.ROLLING_UPDATE
|
||||
if (policy_name in self.update_policy and
|
||||
self.update_policy[policy_name] is not None):
|
||||
pause_time = self.update_policy[policy_name][self.PAUSE_TIME]
|
||||
if iso8601utils.parse_isoduration(pause_time) > 3600:
|
||||
msg = _('Maximum %s is 1 hour.') % self.PAUSE_TIME
|
||||
|
|
|
@ -534,3 +534,42 @@ class RollingUpdatePolicyDiffTest(common.HeatTestCase):
|
|||
def test_update_policy_removed(self):
|
||||
self.validate_update_policy_diff(asg_tmpl_with_updt_policy(),
|
||||
inline_templates.as_heat_template)
|
||||
|
||||
|
||||
class IncorrectUpdatePolicyTest(common.HeatTestCase):
|
||||
def setUp(self):
|
||||
super(IncorrectUpdatePolicyTest, self).setUp()
|
||||
self.stub_keystoneclient(username='test_stack.CfnLBUser')
|
||||
resource._register_class('ResourceWithPropsAndAttrs',
|
||||
generic_resource.ResourceWithPropsAndAttrs)
|
||||
cfg.CONF.set_default('heat_waitcondition_server_url',
|
||||
'http://127.0.0.1:8000/v1/waitcondition')
|
||||
|
||||
def test_with_update_policy_aws(self):
|
||||
t = template_format.parse(inline_templates.as_heat_template)
|
||||
ag = t['resources']['my-group']
|
||||
ag["update_policy"] = {"AutoScalingRollingUpdate": {
|
||||
"MinInstancesInService": "1",
|
||||
"MaxBatchSize": "2",
|
||||
"PauseTime": "PT1S"
|
||||
}}
|
||||
tmpl = template_format.parse(json.dumps(t))
|
||||
stack = utils.parse_stack(tmpl)
|
||||
exc = self.assertRaises(exception.StackValidationFailed,
|
||||
stack.validate)
|
||||
self.assertIn('Unknown Property AutoScalingRollingUpdate',
|
||||
six.text_type(exc))
|
||||
|
||||
def test_with_update_policy_inst_group(self):
|
||||
t = template_format.parse(inline_templates.as_heat_template)
|
||||
ag = t['resources']['my-group']
|
||||
ag["update_policy"] = {"RollingUpdate": {
|
||||
"MinInstancesInService": "1",
|
||||
"MaxBatchSize": "2",
|
||||
"PauseTime": "PT1S"
|
||||
}}
|
||||
tmpl = template_format.parse(json.dumps(t))
|
||||
stack = utils.parse_stack(tmpl)
|
||||
exc = self.assertRaises(exception.StackValidationFailed,
|
||||
stack.validate)
|
||||
self.assertIn('Unknown Property RollingUpdate', six.text_type(exc))
|
||||
|
|
Loading…
Reference in New Issue