Merge "Improve resource.NoActionRequired"

This commit is contained in:
Jenkins
2017-01-25 14:57:26 +00:00
committed by Gerrit Code Review
8 changed files with 84 additions and 76 deletions

View File

@@ -71,7 +71,11 @@ class NoActionRequired(Exception):
Resource subclasses should raise this exception from handle_signal() to
suppress recording of an event corresponding to the signal.
"""
pass
def __init__(self, res_name='Unknown', reason=''):
msg = (_("The resource %(res)s could not perform "
"scaling action: %(reason)s") %
{'res': res_name, 'reason': reason})
super(Exception, self).__init__(six.text_type(msg))
class PollDelay(Exception):
@@ -2162,7 +2166,8 @@ class Resource(object):
pass
except Exception as ex:
LOG.info(_LI('signal %(name)s : %(msg)s'),
{'name': six.text_type(self), 'msg': ex},
{'name': six.text_type(self),
'msg': six.text_type(ex)},
exc_info=True)
failure = exception.ResourceFailure(ex, self)
raise failure

View File

@@ -295,12 +295,7 @@ class AutoScalingGroup(instgrp.InstanceGroup, cooldown.CooldownMixin):
"as there is no change in capacity.") % self.name)
raise resource.NoActionRequired
if not self._is_scaling_allowed():
LOG.info(_LI("%(name)s NOT performing scaling adjustment, "
"cooldown %(cooldown)s") % {
'name': self.name,
'cooldown': self.properties[self.COOLDOWN]})
raise resource.NoActionRequired
self._check_scaling_allowed()
# send a notification before, on-error and on-success.
notif = {

View File

@@ -174,12 +174,7 @@ class AutoScalingPolicy(signal_responder.SignalResponder,
) % {'alarm': self.name,
'group': asgn_id})
if not self._is_scaling_allowed():
LOG.info(_LI("%(name)s NOT performing scaling action, "
"cooldown %(cooldown)s") % {
'name': self.name,
'cooldown': self.properties[self.COOLDOWN]})
raise resource.NoActionRequired
self._check_scaling_allowed()
LOG.info(_LI('%(name)s alarm, adjusting group %(group)s with id '
'%(asgn_id)s by %(filter)s') % {