Skip to content

Commit

Permalink
Ignore pdb (#4718)
Browse files Browse the repository at this point in the history
* cli changes for ignoring PodDisruptionBudget

* addressed the comment.

* resolved some UT errors

* resolve UT errors

* Changed parameter to optional

* Changed parameter to optional

* Changed parameter to optional
  • Loading branch information
Tong Chen authored Apr 29, 2022
1 parent 4c76ecb commit eef9caf
Show file tree
Hide file tree
Showing 8 changed files with 2,113 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/aks-preview/HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
Release History
===============

0.5.65
++++++
* Add `--ignore-pod-disruption-budget` flag for `az aks nodepool delete` for ignoring PodDisruptionBudget.

0.5.64
++++++

Expand Down
7 changes: 7 additions & 0 deletions src/aks-preview/azext_aks_preview/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -1221,6 +1221,13 @@
helps['aks nodepool delete'] = """
type: command
short-summary: Delete the agent pool in the managed Kubernetes cluster.
parameters:
- name: --ignore-pod-disruption-budget -i
type: bool
short-summary: (PREVIEW) ignore-pod-disruption-budget deletes an existing nodepool without considering Pod Disruption Budget.
examples:
- name: Delete an agent pool with ignore-pod-disruption-budget
text: az aks nodepool delete --resource-group MyResourceGroup --cluster-name MyManagedCluster --name nodepool1 --ignore-pod-disruption-budget=true
"""

helps['aks addon'] = """
Expand Down
9 changes: 8 additions & 1 deletion src/aks-preview/azext_aks_preview/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,11 +489,18 @@ def load_arguments(self, _):
c.argument('workload_runtime', arg_type=get_enum_type(workload_runtimes), default=CONST_WORKLOAD_RUNTIME_OCI_CONTAINER)
c.argument('gpu_instance_profile', arg_type=get_enum_type(gpu_instance_profiles))

for scope in ['aks nodepool show', 'aks nodepool delete', 'aks nodepool scale', 'aks nodepool upgrade', 'aks nodepool update']:
for scope in ['aks nodepool show', 'aks nodepool scale', 'aks nodepool upgrade', 'aks nodepool update']:
with self.argument_context(scope) as c:
c.argument('nodepool_name', type=str, options_list=[
'--name', '-n'], validator=validate_nodepool_name, help='The node pool name.')

with self.argument_context('aks nodepool delete') as c:
c.argument('nodepool_name', options_list=[
'--name', '-n'], validator=validate_nodepool_name, help='The node pool name.')
c.argument('ignore_pod_disruption_budget', options_list=[
"--ignore-pod-disruption-budget", "-i"], action=get_three_state_flag(), is_preview=True,
help='delete an AKS nodepool by ignoring PodDisruptionBudget setting')

with self.argument_context('aks nodepool upgrade') as c:
c.argument('max_surge', type=str, validator=validate_max_surge)
c.argument('aks_custom_headers')
Expand Down
3 changes: 2 additions & 1 deletion src/aks-preview/azext_aks_preview/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -1964,6 +1964,7 @@ def aks_agentpool_delete(cmd, # pylint: disable=unused-argument
resource_group_name,
cluster_name,
nodepool_name,
ignore_pod_disruption_budget=None,
no_wait=False):
agentpool_exists = False
instances = client.list(resource_group_name, cluster_name)
Expand All @@ -1976,7 +1977,7 @@ def aks_agentpool_delete(cmd, # pylint: disable=unused-argument
raise CLIError("Node pool {} doesnt exist, "
"use 'aks nodepool list' to get current node pool list".format(nodepool_name))

return sdk_no_wait(no_wait, client.begin_delete, resource_group_name, cluster_name, nodepool_name)
return sdk_no_wait(no_wait, client.begin_delete, resource_group_name, cluster_name, nodepool_name, ignore_pod_disruption_budget=ignore_pod_disruption_budget)


def aks_addon_list_available():
Expand Down
Loading

0 comments on commit eef9caf

Please sign in to comment.