Improve autoscaling error message
If we can't find the autoscaling group name produce a more meaningful error message. Change-Id: Id7ecae67c9ca8eca0c45b365e9a58caee212c2c9 Closes-bug: #1260111
This commit is contained in:
parent
7fd500a5fb
commit
15e2fed46a
|
@ -823,6 +823,11 @@ class ScalingPolicy(signal_responder.SignalResponder, CooldownMixin):
|
|||
|
||||
asgn_id = self.properties[self.AUTO_SCALING_GROUP_NAME]
|
||||
group = self.stack.resource_by_refid(asgn_id)
|
||||
if group is None:
|
||||
raise exception.NotFound(_('Alarm %(alarm)s could not find '
|
||||
'scaling group named "%(group)s"') % {
|
||||
'alarm': self.name,
|
||||
'group': asgn_id})
|
||||
|
||||
logger.info(_('%(name)s Alarm, adjusting Group %(group)s '
|
||||
'by %(filter)s') % {
|
||||
|
|
|
@ -100,6 +100,27 @@ as_template = '''
|
|||
}
|
||||
'''
|
||||
|
||||
as_template_bad_group = '''
|
||||
{
|
||||
"AWSTemplateFormatVersion" : "2010-09-09",
|
||||
"Parameters" : {
|
||||
"ImageId": {"Type": "String"},
|
||||
"KeyName": {"Type": "String"}
|
||||
},
|
||||
"Resources" : {
|
||||
"WebServerScaleUpPolicy" : {
|
||||
"Type" : "AWS::AutoScaling::ScalingPolicy",
|
||||
"Properties" : {
|
||||
"AdjustmentType" : "ChangeInCapacity",
|
||||
"AutoScalingGroupName" : "not a real group",
|
||||
"Cooldown" : "60",
|
||||
"ScalingAdjustment" : "1"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
'''
|
||||
|
||||
|
||||
class AutoScalingTest(HeatTestCase):
|
||||
dummy_instance_id = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa'
|
||||
|
@ -1039,6 +1060,26 @@ class AutoScalingTest(HeatTestCase):
|
|||
rsrc.delete()
|
||||
self.m.VerifyAll()
|
||||
|
||||
def test_scaling_policy_bad_group(self):
|
||||
t = template_format.parse(as_template_bad_group)
|
||||
stack = utils.parse_stack(t, params=self.params)
|
||||
|
||||
self.m.StubOutWithMock(asc.ScalingPolicy, 'keystone')
|
||||
asc.ScalingPolicy.keystone().MultipleTimes().AndReturn(
|
||||
self.fc)
|
||||
|
||||
self.m.ReplayAll()
|
||||
up_policy = self.create_scaling_policy(t, stack,
|
||||
'WebServerScaleUpPolicy')
|
||||
|
||||
alarm_url = up_policy.FnGetAtt('AlarmUrl')
|
||||
self.assertNotEqual(None, alarm_url)
|
||||
ex = self.assertRaises(exception.ResourceFailure, up_policy.signal)
|
||||
self.assertIn('Alarm WebServerScaleUpPolicy could '
|
||||
'not find scaling group', str(ex))
|
||||
|
||||
self.m.VerifyAll()
|
||||
|
||||
def test_scaling_policy_up(self):
|
||||
t = template_format.parse(as_template)
|
||||
stack = utils.parse_stack(t, params=self.params)
|
||||
|
|
Loading…
Reference in New Issue