Merge "Removing CLUSTER_RESIZE from pre-op skip List at min threshold"

This commit is contained in:
Zuul 2024-01-18 06:52:10 +00:00 committed by Gerrit Code Review
commit 7fa6ae780c
3 changed files with 13 additions and 3 deletions

View File

@ -0,0 +1,8 @@
---
fixes:
- |
Excluding CLUSTER_RESIZE from the list of actions that skip pre-op checks
if the cluster is already at the minimum threshold. When the cluster is at
the minimum threshold, pre-operation LB will function with actions such as
CLUSTER_DEL_NODES, CLUSTER_SCALE_IN, NODE_DELETE, and will skip actions
like CLUSTER_REPLACE_NODES and CLUSTER_RESIZE.

View File

@ -670,7 +670,8 @@ class LoadBalancingPolicy(base.Policy):
# except in the case of node replacement
if (
cluster.desired_capacity == cluster.min_size and
action.action != consts.CLUSTER_REPLACE_NODES
action.action not in [consts.CLUSTER_REPLACE_NODES,
consts.CLUSTER_RESIZE]
):
return

View File

@ -1505,6 +1505,7 @@ class TestLoadBalancingPolicyOperations(base.SenlinTestCase):
def test_pre_op_cluster_resize_at_min_threshold(
self, m_cluster_get, m_candidates, *args, **kwargs
):
cluster_id = 'CLUSTER_ID'
cluster = mock.Mock(
user='user1',
project='project1',
@ -1520,10 +1521,10 @@ class TestLoadBalancingPolicyOperations(base.SenlinTestCase):
m_cluster_get.return_value = cluster
policy = lb_policy.LoadBalancingPolicy('test-policy', self.spec)
res = policy.pre_op(cluster_id='CLUSTER_ID', action=action)
res = policy.pre_op(cluster_id=cluster_id, action=action)
self.assertIsNone(res)
m_candidates.assert_not_called()
m_candidates.assert_called_once_with(cluster_id, action)
@mock.patch.object(
lb_policy.LoadBalancingPolicy, '_get_delete_candidates'