From 7ef513dd7918b609abf19712288c3bc98405fb67 Mon Sep 17 00:00:00 2001 From: Nguyen Ngoc Hieu Date: Fri, 12 Jan 2024 17:26:43 +0700 Subject: [PATCH] Removing CLUSTER_RESIZE from pre-op skip List at min threshold Excluding CLUSTER_RESIZE from the list of actions that skip pre-operation checks if the cluster is already at the minimum threshold. When the cluster is at the minimum threshold, pre-op 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. Closes-Bug: #2049191 Change-Id: I00a7ea40f69bafc94ca2bba9f268af7b03344997 --- releasenotes/notes/bug-2049191-8ee2d8352b05cfef.yaml | 8 ++++++++ senlin/policies/lb_policy.py | 3 ++- senlin/tests/unit/policies/test_lb_policy.py | 5 +++-- 3 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 releasenotes/notes/bug-2049191-8ee2d8352b05cfef.yaml diff --git a/releasenotes/notes/bug-2049191-8ee2d8352b05cfef.yaml b/releasenotes/notes/bug-2049191-8ee2d8352b05cfef.yaml new file mode 100644 index 000000000..5895abf8c --- /dev/null +++ b/releasenotes/notes/bug-2049191-8ee2d8352b05cfef.yaml @@ -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. diff --git a/senlin/policies/lb_policy.py b/senlin/policies/lb_policy.py index 3833a6428..639c75c41 100755 --- a/senlin/policies/lb_policy.py +++ b/senlin/policies/lb_policy.py @@ -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 diff --git a/senlin/tests/unit/policies/test_lb_policy.py b/senlin/tests/unit/policies/test_lb_policy.py index 7418d71aa..b2911661b 100644 --- a/senlin/tests/unit/policies/test_lb_policy.py +++ b/senlin/tests/unit/policies/test_lb_policy.py @@ -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'