Skip to content

[AKS] az aks nodepool delete: Add --ignore-pod-disruption-budget option for ignoring PodDisruptionBudget#30196

Merged
yanzhudd merged 10 commits into
Azure:devfrom
tonychen15:dev-ipdb
Feb 21, 2025
Merged

[AKS] az aks nodepool delete: Add --ignore-pod-disruption-budget option for ignoring PodDisruptionBudget#30196
yanzhudd merged 10 commits into
Azure:devfrom
tonychen15:dev-ipdb

Conversation

@tonychen15
Copy link
Copy Markdown
Contributor

@tonychen15 tonychen15 commented Oct 25, 2024

Related command
az aks nodepool delete

Description
Add --ignore-pod-disruption-budget option for ignoring PodDisruptionBudget. This will expedite the nodepool deletion which may be delayed or blocked by PDB.

Testing Guide
Use the command az aks nodepool delete --ignore-pod-disruption-budget to send the request to aks.

History Notes
[AKS] az aks nodepool delete: Add --ignore-pod-disruption-budget option for ignoring PodDisruptionBudget


This checklist is used to make sure that common guidelines for a pull request are followed.

@azure-client-tools-bot-prd
Copy link
Copy Markdown

azure-client-tools-bot-prd Bot commented Oct 25, 2024

️✔️AzureCLI-FullTest
️✔️acr
️✔️2020-09-01-hybrid
️✔️3.12
️✔️3.9
️✔️latest
️✔️3.12
️✔️3.9
️✔️acs
️✔️2020-09-01-hybrid
️✔️3.12
️✔️3.9
️✔️latest
️✔️3.12
️✔️3.9
️✔️advisor
️✔️latest
️✔️3.12
️✔️3.9
️✔️ams
️✔️latest
️✔️3.12
️✔️3.9
️✔️apim
️✔️latest
️✔️3.12
️✔️3.9
️✔️appconfig
️✔️latest
️✔️3.12
️✔️3.9
️✔️appservice
️✔️latest
️✔️3.12
️✔️3.9
️✔️aro
️✔️latest
️✔️3.12
️✔️3.9
️✔️backup
️✔️latest
️✔️3.12
️✔️3.9
️✔️batch
️✔️latest
️✔️3.12
️✔️3.9
️✔️batchai
️✔️latest
️✔️3.12
️✔️3.9
️✔️billing
️✔️latest
️✔️3.12
️✔️3.9
️✔️botservice
️✔️latest
️✔️3.12
️✔️3.9
️✔️cdn
️✔️latest
️✔️3.12
️✔️3.9
️✔️cloud
️✔️latest
️✔️3.12
️✔️3.9
️✔️cognitiveservices
️✔️latest
️✔️3.12
️✔️3.9
️✔️compute_recommender
️✔️latest
️✔️3.12
️✔️3.9
️✔️computefleet
️✔️latest
️✔️3.12
️✔️3.9
️✔️config
️✔️latest
️✔️3.12
️✔️3.9
️✔️configure
️✔️latest
️✔️3.12
️✔️3.9
️✔️consumption
️✔️latest
️✔️3.12
️✔️3.9
️✔️container
️✔️latest
️✔️3.12
️✔️3.9
️✔️containerapp
️✔️latest
️✔️3.12
️✔️3.9
️✔️core
️✔️2018-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️2019-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️2020-09-01-hybrid
️✔️3.12
️✔️3.9
️✔️latest
️✔️3.12
️✔️3.9
️✔️cosmosdb
️✔️latest
️✔️3.12
️✔️3.9
️✔️databoxedge
️✔️2019-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️2020-09-01-hybrid
️✔️3.12
️✔️3.9
️✔️latest
️✔️3.12
️✔️3.9
️✔️dls
️✔️latest
️✔️3.12
️✔️3.9
️✔️dms
️✔️latest
️✔️3.12
️✔️3.9
️✔️eventgrid
️✔️latest
️✔️3.12
️✔️3.9
️✔️eventhubs
️✔️latest
️✔️3.12
️✔️3.9
️✔️feedback
️✔️latest
️✔️3.12
️✔️3.9
️✔️find
️✔️latest
️✔️3.12
️✔️3.9
️✔️hdinsight
️✔️latest
️✔️3.12
️✔️3.9
️✔️identity
️✔️latest
️✔️3.12
️✔️3.9
️✔️iot
️✔️2019-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️2020-09-01-hybrid
️✔️3.12
️✔️3.9
️✔️latest
️✔️3.12
️✔️3.9
️✔️keyvault
️✔️2018-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️2020-09-01-hybrid
️✔️3.12
️✔️3.9
️✔️latest
️✔️3.12
️✔️3.9
️✔️lab
️✔️latest
️✔️3.12
️✔️3.9
️✔️managedservices
️✔️latest
️✔️3.12
️✔️3.9
️✔️maps
️✔️latest
️✔️3.12
️✔️3.9
️✔️marketplaceordering
️✔️latest
️✔️3.12
️✔️3.9
️✔️monitor
️✔️latest
️✔️3.12
️✔️3.9
️✔️mysql
️✔️latest
️✔️3.12
️✔️3.9
️✔️netappfiles
️✔️latest
️✔️3.12
️✔️3.9
️✔️network
️✔️2018-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️latest
️✔️3.12
️✔️3.9
️✔️policyinsights
️✔️latest
️✔️3.12
️✔️3.9
️✔️privatedns
️✔️latest
️✔️3.12
️✔️3.9
️✔️profile
️✔️latest
️✔️3.12
️✔️3.9
️✔️rdbms
️✔️latest
️✔️3.12
️✔️3.9
️✔️redis
️✔️latest
️✔️3.12
️✔️3.9
️✔️relay
️✔️latest
️✔️3.12
️✔️3.9
️✔️resource
️✔️2018-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️2019-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️latest
️✔️3.12
️✔️3.9
️✔️role
️✔️latest
️✔️3.12
️✔️3.9
️✔️search
️✔️latest
️✔️3.12
️✔️3.9
️✔️security
️✔️latest
️✔️3.12
️✔️3.9
️✔️servicebus
️✔️latest
️✔️3.12
️✔️3.9
️✔️serviceconnector
️✔️latest
️✔️3.12
️✔️3.9
️✔️servicefabric
️✔️latest
️✔️3.12
️✔️3.9
️✔️signalr
️✔️latest
️✔️3.12
️✔️3.9
️✔️sql
️✔️latest
️✔️3.12
️✔️3.9
️✔️sqlvm
️✔️latest
️✔️3.12
️✔️3.9
️✔️storage
️✔️2018-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️2019-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️2020-09-01-hybrid
️✔️3.12
️✔️3.9
️✔️latest
️✔️3.12
️✔️3.9
️✔️synapse
️✔️latest
️✔️3.12
️✔️3.9
️✔️telemetry
️✔️2018-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️2019-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️2020-09-01-hybrid
️✔️3.12
️✔️3.9
️✔️latest
️✔️3.12
️✔️3.9
️✔️util
️✔️latest
️✔️3.12
️✔️3.9
️✔️vm
️✔️2018-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️2019-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️2020-09-01-hybrid
️✔️3.12
️✔️3.9
️✔️latest
️✔️3.12
️✔️3.9

@azure-client-tools-bot-prd
Copy link
Copy Markdown

Hi @tonychen15,
Since the current milestone time is less than 7 days, this pr will be reviewed in the next milestone.

@azure-client-tools-bot-prd
Copy link
Copy Markdown

azure-client-tools-bot-prd Bot commented Oct 25, 2024

⚠️AzureCLI-BreakingChangeTest
⚠️acs
rule cmd_name rule_message suggest_message
⚠️ 1006 - ParaAdd aks nodepool delete cmd aks nodepool delete added parameter ignore_pdb

@yonzhan
Copy link
Copy Markdown
Collaborator

yonzhan commented Oct 25, 2024

Thank you for your contribution! We will review the pull request and get back to you soon.

@microsoft-github-policy-service microsoft-github-policy-service Bot added Auto-Assign Auto assign by bot AKS az aks/acs/openshift labels Oct 25, 2024
@tonychen15 tonychen15 changed the title Add ignore-PDB flag to aks nodepool delete command AKS Adds ignore-PDB flag to aks nodepool delete command Oct 25, 2024
@tonychen15 tonychen15 changed the title AKS Adds ignore-PDB flag to aks nodepool delete command [AKS] Adds ignore-PDB flag to aks nodepool delete command Oct 25, 2024
@tonychen15 tonychen15 changed the title [AKS] Adds ignore-PDB flag to aks nodepool delete command [AKS] Adds ignore-pod-disruption-budget flag to aks nodepool delete command Oct 26, 2024
Copy link
Copy Markdown
Member

@FumingZhang FumingZhang left a comment

Choose a reason for hiding this comment

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

Queued live test to validate the change.

Comment on lines +1507 to +1533
def get_ignore_pod_disruption_budget(self) -> bool:
return self._get_ignore_pod_disruption_budget()

def _get_ignore_pod_disruption_budget(self) -> bool:
"""Obtain the value of ignore_pod_disruption_budget, default value is False.

:return: bool
"""
# read the original value passed by the command
ignore_pod_disruption_budget = self.raw_param.get("ignore_pod_disruption_budget", False)

# This parameter does not need dynamic completion.
return ignore_pod_disruption_budget
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think you don't need this as this is not an option for az aks nodepool add/update

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I see. I overlooked your comment in the code. Removed.

Comment on lines +1497 to +1552
def common_get_ignore_pod_disruption_budget(self):
ctx_1 = AKSAgentPoolContext(
self.cmd,
AKSAgentPoolParamDict({
"ignore_pod_disruption_budget": True,
}),
self.models,
DecoratorMode.DELETE,
self.agentpool_decorator_mode,
)
self.assertEqual(ctx_1.get_ignore_pod_disruption_budget(), True)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

And there's no need for the test here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed, thanks.

with self.argument_context("aks nodepool delete") as c:
c.argument(
"ignore_pod_disruption_budget",
options_list=["--ignore-pod-disruption-budget"],
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If the only option form is --ignore-pod-disruption-budget, you could ignore this line. In cli-extensions/aks-preview, it has another shorthand option name -i, do you want to keep it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Got it. I intentionally remove that to make sure CX fully understand what they're doing.

Copy link
Copy Markdown
Contributor Author

@tonychen15 tonychen15 Oct 28, 2024

Choose a reason for hiding this comment

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

Need to add ignore-pdb as ignore-pod-disruption-budget exceeds the maximum length 22.

@tonychen15 tonychen15 force-pushed the dev-ipdb branch 4 times, most recently from e48de17 to c25039f Compare October 28, 2024 20:05
@tonychen15
Copy link
Copy Markdown
Contributor Author

It seems both Python39 and Python312 failed at test case aks_agentpool_create_scale_delete with version 2020-09-01 (https://dev.azure.com/azclitools/public/_build/results?buildId=201476&view=logs&j=4e4d232d-230a-55c9-0730-4c1a9c36b9e5&t=6d1bdb99-245b-5117-da18-01d8df6f72c0&l=1356). Is this failed test case a known issue?

@tonychen15
Copy link
Copy Markdown
Contributor Author

What's the best practice for the option length is too long issue?

"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)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
return sdk_no_wait(no_wait, client.begin_delete, resource_group_name, cluster_name, nodepool_name, ignore_pod_disruption_budget=ignore_pod_disruption_budget)
from azure.cli.core.cloud import get_active_cloud
active_cloud = get_active_cloud(cmd.cli_ctx)
if active_cloud.profile != "latest":
return sdk_no_wait(
no_wait,
client.begin_delete,
resource_group_name,
cluster_name,
nodepool_name,
)
else:
return sdk_no_wait(
no_wait,
client.begin_delete,
resource_group_name,
cluster_name,
nodepool_name,
ignore_pod_disruption_budget=ignore_pod_disruption_budget,
)

something like this can be used as a workaround to support both the old profile with 2020-11-01 as the default API version and the latest profile with the latest API version.

Please move from azure.cli.core.cloud import get_active_cloud to the top of this file

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added. It seems it still doesn't work.

with self.argument_context("aks nodepool delete") as c:
c.argument(
"ignore_pod_disruption_budget",
options_list=["--ignore-pod-disruption-budget, --ignore-pdb"],
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You can add a rule exclusion to src/azure-cli/azure/cli/command_modules/acs/linter_exclusions.yml

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added.

with self.argument_context("aks nodepool delete") as c:
c.argument(
"ignore_pod_disruption_budget",
options_list=["--ignore-pdb"],
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
options_list=["--ignore-pdb"],
options_list=["--ignore-pdb", "--ignore-pod-disruption-budget"],

please also include the default option name

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added back, hope that pylint not to report length too long error.

@FumingZhang
Copy link
Copy Markdown
Member

Requeued live test.

The following cases failed in replay mode as you've changed the behavior of az aks nodepool delete.

  • test_aks_create_with_windows_gmsa
  • test_aks_create_with_windows_msi
  • test_aks_nodepool_create_scale_delete_msi
  • test_aks_nodepool_delete_with_ignore_pod_disruption_budget
  • test_aks_nodepool_system_pool_msi
  • test_aks_update_with_windows_gmsa
  • test_aks_update_with_windows_password

There's a PR #30290 that bumped the default API version merged earlier today. Please rebase from dev branch, requeue the tests and them commit the updated recording files.

@FumingZhang
Copy link
Copy Markdown
Member

/azp run

@azure-pipelines
Copy link
Copy Markdown

Commenter does not have sufficient privileges for PR 30196 in repo Azure/azure-cli

@yanzhudd
Copy link
Copy Markdown
Contributor

Please resolve the CI issues.

short-summary: The value provided will be compared to the ETag of the node pool, if it matches the operation will proceed. If it does not match, the request will be rejected to prevent accidental overwrites. This must not be specified when creating a new agentpool.
- name: --ignore-pdb
type: bool
short-summary: ignore-pdb deletes an existing nodepool without considering Pod Disruption Budget.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
short-summary: ignore-pdb deletes an existing nodepool without considering Pod Disruption Budget.
short-summary: Delete an existing nodepool without considering Pod Disruption Budget.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated.

"ignore_pdb",
options_list=["--ignore-pdb", "--ignore-pod-disruption-budget"],
action='store_true',
help="delete an AKS nodepool by ignoring PodDisruptionBudget setting",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
help="delete an AKS nodepool by ignoring PodDisruptionBudget setting",
help="Delete an AKS nodepool by ignoring PodDisruptionBudget setting",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Changed.

@yanzhudd
Copy link
Copy Markdown
Contributor

Please note Azure CLI will freeze the code on 01/28/2025 10:00 UTC for the upcoming release. If you want to catch this release train, please resolve the comments ASAP, otherwise it has to be postponed to next sprint.

@yanzhudd
Copy link
Copy Markdown
Contributor

please fix the CI issues.

"""
return self.raw_param.get("if_none_match")

def get_ignore_pod_disruption_budget(self) -> bool:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Where is the value of this option passed?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Seems the option is only used by command aks nodepool delete, if that's the case, you could undo your changes in this file as the codes here are only for aks nodepool add/update and aks create/update.

@tonychen15
Copy link
Copy Markdown
Contributor Author

I don't know how this help name --ignore-pdb is invalid. it is accepted by the _params.py, why it is not accepted by _help.py? whether they have different validation criteria? The failed two checks failed at the same place. @yanzhudd @FumingZhang

"
FAIL - HIGH severity: unrecognized_help_parameter_rule
Help-Entry: aks nodepool delete - The following parameter help names are invalid: --ignore-pdb
"

"""
return self.raw_param.get("if_none_match")

def get_ignore_pod_disruption_budget(self) -> bool:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Seems the option is only used by command aks nodepool delete, if that's the case, you could undo your changes in this file as the codes here are only for aks nodepool add/update and aks create/update.

- name: --if-match
type: string
short-summary: The value provided will be compared to the ETag of the node pool, if it matches the operation will proceed. If it does not match, the request will be rejected to prevent accidental overwrites. This must not be specified when creating a new agentpool.
- name: --ignore-pdb
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

the linter CI failed as you added another option form (-i) for this parameter, so you'll need to change this help info to one of the followings (I'm not sure which order the CI rule prefers, but it only considers one to be correct)

Suggested change
- name: --ignore-pdb
- name: --ignore-pdb -i
Suggested change
- name: --ignore-pdb
- name: -i --ignore-pdb

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the suggestion. Hope it will work.
If it works, the git warning is somehow misleading and it should indicate one option is missed but not ignore-pdb is invalid.

Copy link
Copy Markdown
Member

@FumingZhang FumingZhang left a comment

Choose a reason for hiding this comment

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

LGTM

Queued live test to validate the change, test passed!

@tonychen15
Copy link
Copy Markdown
Contributor Author

@jsntcy and @yonzhan could you take a look this test ready PR? Thanks.

@yanzhudd yanzhudd changed the title [AKS] Adds ignore-pod-disruption-budget flag to aks nodepool delete command [AKS] az aks nodepool delete: Add --ignore-pod-disruption-budget option for ignoring PodDisruptionBudget Feb 21, 2025
@yanzhudd yanzhudd merged commit 21210df into Azure:dev Feb 21, 2025
CustardTart32 pushed a commit to CustardTart32/azure-cli that referenced this pull request Feb 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AKS az aks/acs/openshift Auto-Assign Auto assign by bot

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants