Skip to content

Quality improvements for az aks extension and az aks extension type command groups #8794

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

Open
wants to merge 164 commits into
base: main
Choose a base branch
from

Conversation

sophsoph321
Copy link
Contributor

This PR contains the following improvements for the az aks extension and az aks extension type command groups:

  1. Error message for az aks extension create command when the extension type is not in the allowed list of core extensions has been generalized to fit various scenarios
  2. Adds filter for az aks extension show command to check whether the core extension is in the allowed list of core extensions
  3. For the az aks extension type command group, we return a validation error if the user didn't specify a location, or any cluster details (i.e. resource group name and cluster name)

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

Related command

General Guidelines

  • [x ] Have you run azdev style <YOUR_EXT> locally? (pip install azdev required)
  • [ x] Have you run python scripts/ci/test_index.py -q locally? (pip install wheel==0.30.0 required)
  • My extension version conforms to the Extension version schema

For new extensions:

About Extension Publish

There is a pipeline to automatically build, upload and publish extension wheels.
Once your pull request is merged into main branch, a new pull request will be created to update src/index.json automatically.
You only need to update the version information in file setup.py and historical information in file HISTORY.rst in your PR but do not modify src/index.json.

@Copilot Copilot AI review requested due to automatic review settings May 27, 2025 15:08
Copy link

azure-client-tools-bot-prd bot commented May 27, 2025

️✔️Azure CLI Extensions Breaking Change Test
️✔️Non Breaking Changes

@yonzhan
Copy link
Collaborator

yonzhan commented May 27, 2025

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

Copy link

The git hooks are available for azure-cli and azure-cli-extensions repos. They could help you run required checks before creating the PR.

Please sync the latest code with latest dev branch (for azure-cli) or main branch (for azure-cli-extensions).
After that please run the following commands to enable git hooks:

pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR aims to enhance the quality of the az aks extension and az aks extension type command groups by refining error messages, strengthening input validation, and ensuring consistency in help text terminology.

  • Improved error messaging for extension type validation in the create command.
  • Introduced a new helper to filter extensions against the allowed list and applied an updated validator for location/cluster parameters.
  • Updated help texts and release history to align with the new "Cluster Extension" terminology.

Reviewed Changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/aks-preview/setup.py Version bump from 18.0.0b3 to 18.0.0b4.
src/aks-preview/azext_aks_preview/custom.py Updated show command to use the new helper for allowed list filtering.
src/aks-preview/azext_aks_preview/_validators.py Added a new validator (validate_location_cluster_parameters_present) for location/cluster checks.
src/aks-preview/azext_aks_preview/_params.py Updated argument validators to use the new location/cluster validator.
src/aks-preview/azext_aks_preview/_helpers.py Improved the error message for validation failure and introduced get_extension_in_allow_list.
src/aks-preview/azext_aks_preview/_help.py Updated help texts to replace "K8s Extension" with "Cluster Extension" consistently.
src/aks-preview/HISTORY.rst Updated the release history with the new version number and release notes.
Comments suppressed due to low confidence (1)

src/aks-preview/azext_aks_preview/_helpers.py:446

  • [nitpick] The function name get_extension_in_allow_list may be ambiguous since it returns None when the extension type is not allowed. Consider renaming it to filter_extension_in_allow_list to more clearly convey its behavior.
def get_extension_in_allow_list(result):

@@ -442,3 +442,8 @@ def get_all_extensions_in_allow_list(result):
if _check_if_extension_type_is_in_allow_list(obj.extension_type.lower()):
output.append(obj)
return output

def get_extension_in_allow_list(result):
Copy link
Preview

Copilot AI May 27, 2025

Choose a reason for hiding this comment

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

Review whether returning None when the extension does not pass the allowed list check is the best approach for error handling. Consider if raising a ValidationError might provide clearer feedback in the command workflow.

Copilot uses AI. Check for mistakes.

Copy link

Copy link
Member

@matthchr matthchr left a comment

Choose a reason for hiding this comment

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

Looks good to me. I had a few minor comments and one outstanding question for Fuming, as I think the required changes to the recordings don't look quite right to me (or rather they look right but I assume Fuming has another PR where he's already dealing with them?)

@@ -60,7 +60,7 @@ interactions:
User-Agent:
- AZURECLI/2.53.0 azsdk-python-azure-mgmt-resource/23.1.0b2 Python/3.8.10 (Linux-5.15.0-1051-azure-x86_64-with-glibc2.29)
method: GET
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/clitest000001?api-version=2022-09-01
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/clitest000001?api-version=2024-11-01
Copy link
Member

Choose a reason for hiding this comment

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

@FumingZhang - Do you understand why these changes were required?

Do you have an outstanding PR to tackle these that Sophie could rebase onto?

Copy link
Member

Choose a reason for hiding this comment

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

yep, I've applied fix for failed test cases in PR #8798

Copy link
Member

Choose a reason for hiding this comment

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

please rebase from main to drop unrelated changes

@@ -16176,4 +16176,4 @@ def test_aks_loadbalancer_commands(
# self.cmd(
Copy link
Member

Choose a reason for hiding this comment

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

please remove self.cmd('extension add -n k8s-extension') from the init function.

Copy link
Member

Choose a reason for hiding this comment

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

Also, for cases where you need to install an extension, I recommend marking them as @live_only() and you can remove the corresponding recording file

Copy link
Member

@matthchr matthchr left a comment

Choose a reason for hiding this comment

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

I think the _backup.yaml files aren't intentionally added?

)

"""Validates that location, cluster name, and resource group name are not specified at the same time"""
if location and resource_group_name and cluster_name:
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if location and resource_group_name and cluster_name:
if location and (resource_group_name or cluster_name):

So you reject --location + --cluster-name too, which shouldn't be allowed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AKS Auto-Assign Auto assign by bot
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants