Merge "Move NoActionRequired exception back where it belongs"
This commit is contained in:
commit
a0b1916888
|
@ -511,10 +511,6 @@ class SIGHUPInterrupt(HeatException):
|
|||
msg_fmt = _("System SIGHUP signal received.")
|
||||
|
||||
|
||||
class NoActionRequired(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class InvalidServiceVersion(HeatException):
|
||||
msg_fmt = _("Invalid service %(service)s version %(version)s")
|
||||
|
||||
|
|
|
@ -65,6 +65,16 @@ def _register_class(resource_type, resource_class):
|
|||
UpdateReplace = exception.UpdateReplace
|
||||
|
||||
|
||||
# Attention developers about to move this: STOP IT!!!
|
||||
class NoActionRequired(Exception):
|
||||
"""Exception raised when a signal is ignored.
|
||||
|
||||
Resource subclasses should raise this exception from handle_signal() to
|
||||
suppress recording of an event corresponding to the signal.
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
class PollDelay(Exception):
|
||||
"""Exception to delay polling of the resource.
|
||||
|
||||
|
@ -2121,7 +2131,7 @@ class Resource(object):
|
|||
else:
|
||||
reason_string = get_string_details()
|
||||
self._add_event('SIGNAL', self.status, reason_string)
|
||||
except exception.NoActionRequired:
|
||||
except NoActionRequired:
|
||||
# Don't log an event as it just spams the user.
|
||||
pass
|
||||
except Exception as ex:
|
||||
|
|
|
@ -284,7 +284,7 @@ class AutoScalingGroup(instgrp.InstanceGroup, cooldown.CooldownMixin):
|
|||
if self.status != self.COMPLETE:
|
||||
LOG.info(_LI("%s NOT performing scaling adjustment, "
|
||||
"when status is not COMPLETE") % self.name)
|
||||
raise exception.NoActionRequired()
|
||||
raise resource.NoActionRequired
|
||||
|
||||
capacity = grouputils.get_size(self)
|
||||
new_capacity = self._get_new_capacity(capacity, adjustment,
|
||||
|
@ -293,14 +293,14 @@ class AutoScalingGroup(instgrp.InstanceGroup, cooldown.CooldownMixin):
|
|||
if new_capacity == capacity:
|
||||
LOG.info(_LI("%s NOT performing scaling adjustment, "
|
||||
"as there is no change in capacity.") % self.name)
|
||||
raise exception.NoActionRequired()
|
||||
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 exception.NoActionRequired()
|
||||
raise resource.NoActionRequired
|
||||
|
||||
# send a notification before, on-error and on-success.
|
||||
notif = {
|
||||
|
|
|
@ -179,7 +179,7 @@ class AutoScalingPolicy(signal_responder.SignalResponder,
|
|||
"cooldown %(cooldown)s") % {
|
||||
'name': self.name,
|
||||
'cooldown': self.properties[self.COOLDOWN]})
|
||||
raise exception.NoActionRequired()
|
||||
raise resource.NoActionRequired
|
||||
|
||||
LOG.info(_LI('%(name)s alarm, adjusting group %(group)s with id '
|
||||
'%(asgn_id)s by %(filter)s') % {
|
||||
|
@ -194,12 +194,13 @@ class AutoScalingPolicy(signal_responder.SignalResponder,
|
|||
self.properties[self.ADJUSTMENT_TYPE],
|
||||
self.properties[self.MIN_ADJUSTMENT_STEP])
|
||||
size_changed = True
|
||||
except Exception as ex:
|
||||
if not isinstance(ex, exception.NoActionRequired):
|
||||
LOG.error(_LE("Error in performing scaling adjustment with "
|
||||
"%(name)s alarm for group %(group)s.") % {
|
||||
'name': self.name,
|
||||
'group': group.name})
|
||||
except resource.NoActionRequired:
|
||||
raise
|
||||
except Exception:
|
||||
LOG.error(_LE("Error in performing scaling adjustment with "
|
||||
"%(name)s alarm for group %(group)s.") % {
|
||||
'name': self.name,
|
||||
'group': group.name})
|
||||
raise
|
||||
finally:
|
||||
self._finished_scaling("%s : %s" % (
|
||||
|
|
|
@ -18,6 +18,7 @@ import six
|
|||
from heat.common import exception
|
||||
from heat.common import grouputils
|
||||
from heat.common import template_format
|
||||
from heat.engine import resource
|
||||
from heat.engine import rsrc_defn
|
||||
from heat.tests.autoscaling import inline_templates
|
||||
from heat.tests import common
|
||||
|
@ -116,7 +117,7 @@ class TestGroupAdjust(common.HeatTestCase):
|
|||
dont_call = self.patchobject(self.group, 'resize')
|
||||
self.patchobject(self.group, '_is_scaling_allowed',
|
||||
return_value=False)
|
||||
self.assertRaises(exception.NoActionRequired,
|
||||
self.assertRaises(resource.NoActionRequired,
|
||||
self.group.adjust, 1)
|
||||
self.assertEqual([], dont_call.call_args_list)
|
||||
|
||||
|
@ -126,7 +127,7 @@ class TestGroupAdjust(common.HeatTestCase):
|
|||
resize = self.patchobject(self.group, 'resize')
|
||||
finished_scaling = self.patchobject(self.group, '_finished_scaling')
|
||||
notify = self.patch('heat.engine.notification.autoscaling.send')
|
||||
self.assertRaises(exception.NoActionRequired,
|
||||
self.assertRaises(resource.NoActionRequired,
|
||||
self.group.adjust, 3,
|
||||
adjustment_type='ExactCapacity')
|
||||
expected_notifies = []
|
||||
|
|
|
@ -19,6 +19,7 @@ import six
|
|||
|
||||
from heat.common import exception
|
||||
from heat.common import template_format
|
||||
from heat.engine import resource
|
||||
from heat.engine import scheduler
|
||||
from heat.tests.autoscaling import inline_templates
|
||||
from heat.tests import common
|
||||
|
@ -81,11 +82,11 @@ class TestAutoScalingPolicy(common.HeatTestCase):
|
|||
'my-policy')
|
||||
group = stack['my-group']
|
||||
self.patchobject(group, 'adjust',
|
||||
side_effect=exception.NoActionRequired())
|
||||
side_effect=resource.NoActionRequired())
|
||||
mock_fin_scaling = self.patchobject(up_policy, '_finished_scaling')
|
||||
with mock.patch.object(up_policy, '_is_scaling_allowed',
|
||||
return_value=True) as mock_isa:
|
||||
self.assertRaises(exception.NoActionRequired,
|
||||
self.assertRaises(resource.NoActionRequired,
|
||||
up_policy.handle_signal)
|
||||
mock_isa.assert_called_once_with()
|
||||
mock_fin_scaling.assert_called_once_with('change_in_capacity : 1',
|
||||
|
@ -118,7 +119,7 @@ class TestAutoScalingPolicy(common.HeatTestCase):
|
|||
side_effect=AssertionError) as dont_call:
|
||||
with mock.patch.object(pol, '_is_scaling_allowed',
|
||||
return_value=False) as mock_cip:
|
||||
self.assertRaises(exception.NoActionRequired,
|
||||
self.assertRaises(resource.NoActionRequired,
|
||||
pol.handle_signal, details=test)
|
||||
mock_cip.assert_called_once_with()
|
||||
self.assertEqual([], dont_call.call_args_list)
|
||||
|
|
|
@ -20,6 +20,7 @@ from heat.common import exception
|
|||
from heat.common import grouputils
|
||||
from heat.common import template_format
|
||||
from heat.engine.clients.os import nova
|
||||
from heat.engine import resource
|
||||
from heat.engine import rsrc_defn
|
||||
from heat.engine import scheduler
|
||||
from heat.tests.autoscaling import inline_templates
|
||||
|
@ -303,7 +304,7 @@ class TestGroupAdjust(common.HeatTestCase):
|
|||
dont_call = self.patchobject(self.group, 'resize')
|
||||
self.patchobject(self.group, '_is_scaling_allowed',
|
||||
return_value=False)
|
||||
self.assertRaises(exception.NoActionRequired,
|
||||
self.assertRaises(resource.NoActionRequired,
|
||||
self.group.adjust, 1)
|
||||
self.assertEqual([], dont_call.call_args_list)
|
||||
|
||||
|
@ -313,7 +314,7 @@ class TestGroupAdjust(common.HeatTestCase):
|
|||
resize = self.patchobject(self.group, 'resize')
|
||||
finished_scaling = self.patchobject(self.group, '_finished_scaling')
|
||||
notify = self.patch('heat.engine.notification.autoscaling.send')
|
||||
self.assertRaises(exception.NoActionRequired,
|
||||
self.assertRaises(resource.NoActionRequired,
|
||||
self.group.adjust, 3,
|
||||
adjustment_type='ExactCapacity')
|
||||
expected_notifies = []
|
||||
|
@ -327,7 +328,7 @@ class TestGroupAdjust(common.HeatTestCase):
|
|||
resize = self.patchobject(self.group, 'resize')
|
||||
finished_scaling = self.patchobject(self.group, '_finished_scaling')
|
||||
notify = self.patch('heat.engine.notification.autoscaling.send')
|
||||
self.assertRaises(exception.NoActionRequired,
|
||||
self.assertRaises(resource.NoActionRequired,
|
||||
self.group.adjust, 3,
|
||||
adjustment_type='ExactCapacity')
|
||||
expected_notifies = []
|
||||
|
|
|
@ -19,6 +19,7 @@ import six
|
|||
|
||||
from heat.common import exception
|
||||
from heat.common import template_format
|
||||
from heat.engine import resource
|
||||
from heat.engine.resources.aws.autoscaling import scaling_policy as aws_sp
|
||||
from heat.engine import scheduler
|
||||
from heat.tests.autoscaling import inline_templates
|
||||
|
@ -87,11 +88,11 @@ class TestAutoScalingPolicy(common.HeatTestCase):
|
|||
'WebServerScaleUpPolicy')
|
||||
group = stack['WebServerGroup']
|
||||
self.patchobject(group, 'adjust',
|
||||
side_effect=exception.NoActionRequired())
|
||||
side_effect=resource.NoActionRequired())
|
||||
mock_fin_scaling = self.patchobject(up_policy, '_finished_scaling')
|
||||
with mock.patch.object(up_policy, '_is_scaling_allowed',
|
||||
return_value=True) as mock_isa:
|
||||
self.assertRaises(exception.NoActionRequired,
|
||||
self.assertRaises(resource.NoActionRequired,
|
||||
up_policy.handle_signal)
|
||||
mock_isa.assert_called_once_with()
|
||||
mock_fin_scaling.assert_called_once_with('ChangeInCapacity : 1',
|
||||
|
@ -124,7 +125,7 @@ class TestAutoScalingPolicy(common.HeatTestCase):
|
|||
side_effect=AssertionError) as dont_call:
|
||||
with mock.patch.object(pol, '_is_scaling_allowed',
|
||||
return_value=False) as mock_isa:
|
||||
self.assertRaises(exception.NoActionRequired,
|
||||
self.assertRaises(resource.NoActionRequired,
|
||||
pol.handle_signal, details=test)
|
||||
mock_isa.assert_called_once_with()
|
||||
self.assertEqual([], dont_call.call_args_list)
|
||||
|
|
|
@ -22,6 +22,7 @@ from heat.common import exception
|
|||
from heat.common import template_format
|
||||
from heat.engine.clients.os import heat_plugin
|
||||
from heat.engine.clients.os import swift
|
||||
from heat.engine import resource
|
||||
from heat.engine import scheduler
|
||||
from heat.engine import stack as stk
|
||||
from heat.engine import template
|
||||
|
@ -536,7 +537,7 @@ class SignalTest(common.HeatTestCase):
|
|||
|
||||
stack = self._create_stack(TEMPLATE_CFN_SIGNAL)
|
||||
|
||||
mock_handle.side_effect = exception.NoActionRequired()
|
||||
mock_handle.side_effect = resource.NoActionRequired()
|
||||
rsrc = stack['signal_handler']
|
||||
|
||||
self.assertEqual((rsrc.CREATE, rsrc.COMPLETE), rsrc.state)
|
||||
|
|
Loading…
Reference in New Issue