From 0799acf939b83015398d71e39c6800bbdc14f8ab Mon Sep 17 00:00:00 2001 From: Theodoros Tsioutsias Date: Tue, 23 Jun 2020 16:41:49 +0000 Subject: [PATCH] Nodegroup min_node_count should default to 0 This changes the default value for nodegroups min_node_count to 0. Scaling nodegroups to 0 is also allowed. Change-Id: I74dd0d34990b71b290b6ccbe707afb8cc7ae7340 Depends-On: Id63459d0fe9836e678bb7569f23d29eabc225e9e story: 2007851 task: 40147 --- magnumclient/osc/v1/nodegroups.py | 2 +- magnumclient/tests/osc/unit/v1/test_clusters.py | 15 +++++++++++++++ magnumclient/tests/osc/unit/v1/test_nodegroups.py | 2 +- magnumclient/tests/v1/test_nodegroups.py | 4 ++-- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/magnumclient/osc/v1/nodegroups.py b/magnumclient/osc/v1/nodegroups.py index afb58704..b006051b 100644 --- a/magnumclient/osc/v1/nodegroups.py +++ b/magnumclient/osc/v1/nodegroups.py @@ -78,7 +78,7 @@ class CreateNodeGroup(command.Command): parser.add_argument('--min-nodes', dest='min_node_count', type=int, - default=1, + default=0, metavar='', help='The nodegroup minimum node count.') parser.add_argument('--max-nodes', diff --git a/magnumclient/tests/osc/unit/v1/test_clusters.py b/magnumclient/tests/osc/unit/v1/test_clusters.py index 9753dea7..8b7359c4 100644 --- a/magnumclient/tests/osc/unit/v1/test_clusters.py +++ b/magnumclient/tests/osc/unit/v1/test_clusters.py @@ -499,6 +499,21 @@ class TestClusterResize(TestCluster): "UUID1", 2, None, None ) + def test_cluster_resize_to_zero_pass(self): + arglist = ['foo', '0'] + verifylist = [ + ('cluster', 'foo'), + ('node_count', 0), + ('nodes_to_remove', None), + ('nodegroup', None) + ] + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + + self.cmd.take_action(parsed_args) + self.clusters_mock.resize.assert_called_with( + "UUID1", 0, None, None + ) + class TestClusterUpgrade(TestCluster): diff --git a/magnumclient/tests/osc/unit/v1/test_nodegroups.py b/magnumclient/tests/osc/unit/v1/test_nodegroups.py index 199fea8a..c027e75c 100644 --- a/magnumclient/tests/osc/unit/v1/test_nodegroups.py +++ b/magnumclient/tests/osc/unit/v1/test_nodegroups.py @@ -47,7 +47,7 @@ class TestNodeGroupCreate(TestNodeGroup): 'name': 'fake-nodegroup', 'node_count': 1, 'role': 'worker', - 'min_node_count': 1, + 'min_node_count': 0, 'max_node_count': None, } diff --git a/magnumclient/tests/v1/test_nodegroups.py b/magnumclient/tests/v1/test_nodegroups.py index 40cbcf66..720c3044 100644 --- a/magnumclient/tests/v1/test_nodegroups.py +++ b/magnumclient/tests/v1/test_nodegroups.py @@ -37,7 +37,7 @@ NODEGROUP1 = { 'is_default': True, 'role': 'worker', 'max_node_count': 10, - 'min_node_count': 1 + 'min_node_count': 0 } NODEGROUP2 = { 'id': 124, @@ -53,7 +53,7 @@ NODEGROUP2 = { 'is_default': True, 'role': 'master', 'max_node_count': 10, - 'min_node_count': 1 + 'min_node_count': 0 } CREATE_NODEGROUP = copy.deepcopy(NODEGROUP1)