Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/azure-cli/azure/cli/command_modules/acs/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -985,10 +985,10 @@
short-summary: Enable cluster autoscaler.
- name: --min-count
type: int
short-summary: Minimum nodes count used for autoscaler, when "--enable-cluster-autoscaler" specified. Please specify the value in the range of [1, 1000]
short-summary: Minimum nodes count used for autoscaler, when "--enable-cluster-autoscaler" specified. Please specify the value in the range of [0, 1000] for user nodepool, and [1,1000] for system nodepool.
- name: --max-count
type: int
short-summary: Maximum nodes count used for autoscaler, when "--enable-cluster-autoscaler" specified. Please specify the value in the range of [1, 1000]
short-summary: Maximum nodes count used for autoscaler, when "--enable-cluster-autoscaler" specified. Please specify the value in the range of [0, 1000] for user nodepool, and [1,1000] for system nodepool.
- name: --scale-down-mode
type: string
short-summary: "Describe how VMs are added to or removed from nodepools."
Expand Down Expand Up @@ -1101,10 +1101,10 @@
short-summary: Update min-count or max-count for cluster autoscaler.
- name: --min-count
type: int
short-summary: Minimum nodes count used for autoscaler, when "--enable-cluster-autoscaler" specified. Please specify the value in the range of [1, 1000]
short-summary: Minimum nodes count used for autoscaler, when "--enable-cluster-autoscaler" specified. Please specify the value in the range of [0, 1000] for user nodepool, and [1,1000] for system nodepool.
- name: --max-count
type: int
short-summary: Maximum nodes count used for autoscaler, when "--enable-cluster-autoscaler" specified. Please specify the value in the range of [1, 1000]
short-summary: Maximum nodes count used for autoscaler, when "--enable-cluster-autoscaler" specified. Please specify the value in the range of [0, 1000] for user nodepool, and [1,1000] for system nodepool.
- name: --scale-down-mode
type: string
short-summary: "Describe how VMs are added to or removed from nodepools."
Expand Down
10 changes: 5 additions & 5 deletions src/azure-cli/azure/cli/command_modules/acs/_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,13 +224,13 @@ def validate_nat_gateway_idle_timeout(namespace):


def validate_nodes_count(namespace):
"""Validates that min_count and max_count is set between 1-100"""
"""Validates that min_count and max_count is set between 0-1000"""
if namespace.min_count is not None:
if namespace.min_count < 1 or namespace.min_count > 100:
raise CLIError('--min-count must be in the range [1,100]')
if namespace.min_count < 0 or namespace.min_count > 1000:
raise CLIError('--min-count must be in the range [0,1000]')
if namespace.max_count is not None:
if namespace.max_count < 1 or namespace.max_count > 100:
raise CLIError('--max-count must be in the range [1,100]')
if namespace.max_count < 0 or namespace.max_count > 1000:
raise CLIError('--max-count must be in the range [0,1000]')


def validate_taints(namespace):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ def __validate_counts_in_autoscaler(
enable_cluster_autoscaler,
min_count,
max_count,
mode,
decorator_mode,
) -> None:
"""Helper function to check the validity of serveral count-related parameters in autoscaler.
Expand Down Expand Up @@ -201,6 +202,11 @@ def __validate_counts_in_autoscaler(
raise InvalidArgumentValueError(
"node-count is not in the range of min-count and max-count"
)
if mode == CONST_NODEPOOL_MODE_SYSTEM:
if min_count < 1:
raise InvalidArgumentValueError(
"Value of min-count should be greater than or equal to 1 for System node pools"
)
else:
if min_count is not None or max_count is not None:
option_name = "--enable-cluster-autoscaler"
Expand Down Expand Up @@ -636,6 +642,7 @@ def get_node_count_and_enable_cluster_autoscaler_min_max_count(
enable_cluster_autoscaler,
min_count,
max_count,
mode=self.get_mode(),
decorator_mode=DecoratorMode.CREATE,
)
return node_count, enable_cluster_autoscaler, min_count, max_count
Expand Down Expand Up @@ -701,6 +708,7 @@ def get_update_enable_disable_cluster_autoscaler_and_min_max_count(
enable_cluster_autoscaler or update_cluster_autoscaler,
min_count,
max_count,
mode=self.get_mode(),
decorator_mode=DecoratorMode.UPDATE,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,30 +156,37 @@ def common_validate_counts_in_autoscaler(self):
self.cmd, AKSAgentPoolParamDict({}), self.models, DecoratorMode.CREATE, self.agentpool_decorator_mode
)
# default
ctx._AKSAgentPoolContext__validate_counts_in_autoscaler(3, False, None, None, DecoratorMode.CREATE)
ctx._AKSAgentPoolContext__validate_counts_in_autoscaler(3, False, None, None, CONST_NODEPOOL_MODE_SYSTEM, DecoratorMode.CREATE)

# custom value
ctx._AKSAgentPoolContext__validate_counts_in_autoscaler(5, True, 1, 10, DecoratorMode.CREATE)
ctx._AKSAgentPoolContext__validate_counts_in_autoscaler(5, True, 1, 10, CONST_NODEPOOL_MODE_SYSTEM, DecoratorMode.CREATE)

# fail on min_count/max_count not specified
with self.assertRaises(RequiredArgumentMissingError):
ctx._AKSAgentPoolContext__validate_counts_in_autoscaler(5, True, None, None, DecoratorMode.CREATE)
ctx._AKSAgentPoolContext__validate_counts_in_autoscaler(5, True, None, None, CONST_NODEPOOL_MODE_SYSTEM, DecoratorMode.CREATE)

# fail on min_count > max_count
with self.assertRaises(InvalidArgumentValueError):
ctx._AKSAgentPoolContext__validate_counts_in_autoscaler(5, True, 3, 1, DecoratorMode.CREATE)
ctx._AKSAgentPoolContext__validate_counts_in_autoscaler(5, True, 3, 1, CONST_NODEPOOL_MODE_SYSTEM, DecoratorMode.CREATE)

# fail on node_count < min_count in create mode
with self.assertRaises(InvalidArgumentValueError):
ctx._AKSAgentPoolContext__validate_counts_in_autoscaler(5, True, 7, 10, DecoratorMode.CREATE)
ctx._AKSAgentPoolContext__validate_counts_in_autoscaler(5, True, 7, 10, CONST_NODEPOOL_MODE_SYSTEM, DecoratorMode.CREATE)

# skip node_count check in update mode
ctx._AKSAgentPoolContext__validate_counts_in_autoscaler(5, True, 7, 10, DecoratorMode.UPDATE)
ctx._AKSAgentPoolContext__validate_counts_in_autoscaler(None, True, 7, 10, DecoratorMode.UPDATE)
ctx._AKSAgentPoolContext__validate_counts_in_autoscaler(5, True, 7, 10, CONST_NODEPOOL_MODE_SYSTEM, DecoratorMode.UPDATE)
ctx._AKSAgentPoolContext__validate_counts_in_autoscaler(None, True, 7, 10, CONST_NODEPOOL_MODE_SYSTEM, DecoratorMode.UPDATE)

# fail on enable_cluster_autoscaler not specified
with self.assertRaises(RequiredArgumentMissingError):
ctx._AKSAgentPoolContext__validate_counts_in_autoscaler(5, False, 3, None, DecoratorMode.UPDATE)
ctx._AKSAgentPoolContext__validate_counts_in_autoscaler(5, False, 3, None, CONST_NODEPOOL_MODE_SYSTEM, DecoratorMode.UPDATE)

# min_count set to 0 for user node pools
ctx._AKSAgentPoolContext__validate_counts_in_autoscaler(0, True, 0, 1, CONST_NODEPOOL_MODE_USER, DecoratorMode.CREATE)

# fail on min_count < 1 for system node pools
with self.assertRaises(InvalidArgumentValueError):
ctx._AKSAgentPoolContext__validate_counts_in_autoscaler(1, True, 0, 1, CONST_NODEPOOL_MODE_SYSTEM, DecoratorMode.CREATE)

def common_get_resource_group_name(self):
# default
Expand Down