Add 'cooldown' for scaling policy
Since we have removed 'cooldown' from most policies, we need to add it back to the scaling policy because it is a required property there. Change-Id: Ic3da7c18520a13b59401f2cbdf1be915e9f8c0bf
This commit is contained in:
parent
bcb1065513
commit
b8c696e2cb
|
@ -21,3 +21,6 @@ properties:
|
|||
# cluster size to min_size or increase cluster size to max_size
|
||||
# Default False means reject scaling request directly.
|
||||
best_effort: True
|
||||
|
||||
# Number of seconds before allowing the cluster to be resized again.
|
||||
cooldown: 120
|
||||
|
|
|
@ -50,8 +50,10 @@ class ScalingPolicy(base.Policy):
|
|||
|
||||
_ADJUSTMENT_KEYS = (
|
||||
ADJUSTMENT_TYPE, ADJUSTMENT_NUMBER, MIN_STEP, BEST_EFFORT,
|
||||
COOLDOWN,
|
||||
) = (
|
||||
'type', 'number', 'min_step', 'best_effort',
|
||||
'cooldown',
|
||||
)
|
||||
|
||||
properties_schema = {
|
||||
|
@ -88,6 +90,12 @@ class ScalingPolicy(base.Policy):
|
|||
'cluster will break the size limitation'),
|
||||
default=False,
|
||||
),
|
||||
COOLDOWN: schema.Integer(
|
||||
_('Number of seconds to hold the cluster for cool-down '
|
||||
'before allowing cluster to be resized again.'),
|
||||
default=0,
|
||||
),
|
||||
|
||||
}
|
||||
),
|
||||
}
|
||||
|
@ -103,6 +111,7 @@ class ScalingPolicy(base.Policy):
|
|||
self.adjustment_number = adjustment[self.ADJUSTMENT_NUMBER]
|
||||
self.adjustment_min_step = adjustment[self.MIN_STEP]
|
||||
self.best_effort = adjustment[self.BEST_EFFORT]
|
||||
self.cooldown = adjustment[self.COOLDOWN]
|
||||
|
||||
def _calculate_adjustment_count(self, current_size):
|
||||
'''Calculate adjustment count based on current_size'''
|
||||
|
|
|
@ -38,6 +38,7 @@ class TestScalingPolicy(base.SenlinTestCase):
|
|||
'number': 1,
|
||||
'min_step': 1,
|
||||
'best_effort': False,
|
||||
'cooldown': 3,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -109,6 +110,7 @@ class TestScalingPolicy(base.SenlinTestCase):
|
|||
self.assertEqual(adjustment['number'], policy.adjustment_number)
|
||||
self.assertEqual(adjustment['min_step'], policy.adjustment_min_step)
|
||||
self.assertEqual(adjustment['best_effort'], policy.best_effort)
|
||||
self.assertEqual(adjustment['cooldown'], policy.cooldown)
|
||||
|
||||
def test_policy_init_default_value(self):
|
||||
self.spec['properties']['adjustment'] = {}
|
||||
|
@ -121,6 +123,7 @@ class TestScalingPolicy(base.SenlinTestCase):
|
|||
self.assertEqual(1, policy.adjustment_number)
|
||||
self.assertEqual(1, policy.adjustment_min_step)
|
||||
self.assertFalse(policy.best_effort)
|
||||
self.assertEqual(0, policy.cooldown)
|
||||
|
||||
def test_calculate_adjustment_count(self):
|
||||
adjustment = self.spec['properties']['adjustment']
|
||||
|
|
Loading…
Reference in New Issue