Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AKS] Allow aks nodepool update --node-taints #4363

Merged
merged 10 commits into from
Feb 7, 2022
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
5 changes: 4 additions & 1 deletion src/aks-preview/azext_aks_preview/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -977,7 +977,7 @@
short-summary: "Describes how VMs are added to or removed from nodepools."
- name: --node-taints
type: string
short-summary: The node taints for the node pool. You can't change the node taints through CLI after the node pool is created.
short-summary: The node taints for the node pool.
- name: --priority
type: string
short-summary: The priority of the node pool.
Expand Down Expand Up @@ -1100,6 +1100,9 @@
- name: --labels
type: string
short-summary: The node labels for the node pool. See https://aka.ms/node-labels for syntax of labels.
- name: --node-taints
type: string
short-summary: The node taints for the node pool.
examples:
- name: Enable cluster-autoscaler within node count range [1,5]
text: az aks nodepool update --enable-cluster-autoscaler --min-count 1 --max-count 5 -g MyResourceGroup -n nodepool1 --cluster-name MyManagedCluster
Expand Down
3 changes: 2 additions & 1 deletion src/aks-preview/azext_aks_preview/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ def load_arguments(self, _):
c.argument('enable_fips_image', action='store_true')
c.argument('enable_cluster_autoscaler', options_list=["--enable-cluster-autoscaler", "-e"], action='store_true')
c.argument('scale_down_mode', arg_type=get_enum_type([CONST_SCALE_DOWN_MODE_DELETE, CONST_SCALE_DOWN_MODE_DEALLOCATE]))
c.argument('node_taints', type=str, validator=validate_taints)
c.argument('node_taints', validator=validate_taints)
c.argument('priority', arg_type=get_enum_type([CONST_SCALE_SET_PRIORITY_REGULAR, CONST_SCALE_SET_PRIORITY_SPOT]), validator=validate_priority)
c.argument('eviction_policy', arg_type=get_enum_type([CONST_SPOT_EVICTION_POLICY_DELETE, CONST_SPOT_EVICTION_POLICY_DEALLOCATE]), validator=validate_eviction_policy)
c.argument('spot_max_price', type=float, validator=validate_spot_max_price)
Expand Down Expand Up @@ -282,6 +282,7 @@ def load_arguments(self, _):
c.argument('mode', arg_type=get_enum_type([CONST_NODEPOOL_MODE_SYSTEM, CONST_NODEPOOL_MODE_USER]))
c.argument('max_surge', type=str, validator=validate_max_surge)
c.argument('labels', nargs='*', validator=validate_nodepool_labels)
c.argument('node_taints', validator=validate_taints)

with self.argument_context('aks addon show') as c:
c.argument('addon', options_list=['--addon', '-a'], validator=validate_addon)
Expand Down
17 changes: 15 additions & 2 deletions src/aks-preview/azext_aks_preview/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -1767,19 +1767,32 @@ def aks_agentpool_update(cmd, # pylint: disable=unused-argument
max_surge=None,
mode=None,
labels=None,
node_taints=None,
no_wait=False):

update_autoscaler = enable_cluster_autoscaler + \
disable_cluster_autoscaler + update_cluster_autoscaler

if (update_autoscaler != 1 and not tags and not scale_down_mode and not mode and not max_surge and labels is None):
if (update_autoscaler != 1 and not tags and not scale_down_mode and not mode and not max_surge and labels is None and node_taints is None):
raise CLIError('Please specify one or more of "--enable-cluster-autoscaler" or '
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the specific error type ArgumentUsageError instead of CLIError

'"--disable-cluster-autoscaler" or '
'"--update-cluster-autoscaler" or '
'"--tags" or "--mode" or "--max-surge" or "--scale-down-mode" or "--labels"')
'"--tags" or "--mode" or "--max-surge" or "--scale-down-mode" or "--labels" or "--node-taints')

instance = client.get(resource_group_name, cluster_name, nodepool_name)

if node_taints is not None:
taints_array = []
if node_taints != '':
for taint in node_taints.split(','):
try:
taint = taint.strip()
taints_array.append(taint)
except ValueError:
raise InvalidArgumentValueError(
'Taint does not match allowed values. Expect value such as "special=true:NoSchedule".')
instance.node_taints = taints_array

if min_count is None or max_count is None:
if enable_cluster_autoscaler or update_cluster_autoscaler:
raise CLIError('Please specify both min-count and max-count when --enable-cluster-autoscaler or '
Expand Down
Loading