New version of k8s-extension CLI (v1.8.0) using API version 2025-03-01#10045
Open
prasannajsns wants to merge 36 commits into
Open
New version of k8s-extension CLI (v1.8.0) using API version 2025-03-01#10045prasannajsns wants to merge 36 commits into
prasannajsns wants to merge 36 commits into
Conversation
…ension existence check
…nodes-ext-cli-customization Add CLI customization for the microsoft.virtualnodes partner extension type for AKS
…port issues for azure-mgmt-network
Fix validations for version and auto-upgrade-mode combinations and im…
|
Validation for Breaking Change Starting...
Thanks for your contribution! |
|
Hi @prasannajsns, |
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request updates the k8s-extension Azure CLI extension to v1.8.0, including migrating the underlying Extensions API version to 2025-03-01 via newly vendored SDKs and adding new end-user functionality (notably az k8s-extension troubleshoot) plus partner-extension updates.
Changes:
- Bump extension version to
1.8.0, update release history, and add runtime dependencies (kubernetes client, oras, azure-mgmt-network). - Vendor a new
v2025_03_01SDK profile and wire it into the multi-api client selection and tests/recordings. - Add
az k8s-extension troubleshootcommand and supporting diagnostics collection utilities; extend partner extensions (e.g., VirtualNodes) and addauto_upgrade_modesupport in partner extension models.
Reviewed changes
Copilot reviewed 55 out of 55 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| src/k8s-extension/setup.py | Adds dependencies and bumps extension version to 1.8.0. |
| src/k8s-extension/HISTORY.rst | Adds 1.8.0 release notes (API version migration). |
| src/k8s-extension/azext_k8s_extension/vendored_sdks/v2025_03_01/py.typed | Marks vendored SDK package as typed (PEP 561). |
| src/k8s-extension/azext_k8s_extension/vendored_sdks/v2025_03_01/operations/_patch.py | Generated customization hook for sync operations. |
| src/k8s-extension/azext_k8s_extension/vendored_sdks/v2025_03_01/operations/init.py | Exposes generated sync operations and patch hook. |
| src/k8s-extension/azext_k8s_extension/vendored_sdks/v2025_03_01/models/_patch.py | Generated customization hook for models. |
| src/k8s-extension/azext_k8s_extension/vendored_sdks/v2025_03_01/models/_models.py | Adds generated models for 2025-03-01 profile. |
| src/k8s-extension/azext_k8s_extension/vendored_sdks/v2025_03_01/models/_enums.py | Adds generated enums for 2025-03-01 profile. |
| src/k8s-extension/azext_k8s_extension/vendored_sdks/v2025_03_01/models/init.py | Exports generated models/enums and patch hook. |
| src/k8s-extension/azext_k8s_extension/vendored_sdks/v2025_03_01/aio/operations/_patch.py | Generated customization hook for async operations. |
| src/k8s-extension/azext_k8s_extension/vendored_sdks/v2025_03_01/aio/operations/_operations.py | Adds generated async operations for 2025-03-01 profile. |
| src/k8s-extension/azext_k8s_extension/vendored_sdks/v2025_03_01/aio/operations/init.py | Exposes generated async operations and patch hook. |
| src/k8s-extension/azext_k8s_extension/vendored_sdks/v2025_03_01/aio/_patch.py | Generated customization hook for async client package. |
| src/k8s-extension/azext_k8s_extension/vendored_sdks/v2025_03_01/aio/_configuration.py | Adds generated async client configuration for 2025-03-01. |
| src/k8s-extension/azext_k8s_extension/vendored_sdks/v2025_03_01/aio/_client.py | Adds generated async client for 2025-03-01. |
| src/k8s-extension/azext_k8s_extension/vendored_sdks/v2025_03_01/aio/init.py | Exports async client for 2025-03-01. |
| src/k8s-extension/azext_k8s_extension/vendored_sdks/v2025_03_01/_version.py | Adds generated version marker for vendored SDK package. |
| src/k8s-extension/azext_k8s_extension/vendored_sdks/v2025_03_01/_utils/model_base.py | Adds generated model/serialization infrastructure. |
| src/k8s-extension/azext_k8s_extension/vendored_sdks/v2025_03_01/_utils/init.py | Adds generated utils package init. |
| src/k8s-extension/azext_k8s_extension/vendored_sdks/v2025_03_01/_patch.py | Generated customization hook for sync client package. |
| src/k8s-extension/azext_k8s_extension/vendored_sdks/v2025_03_01/_configuration.py | Adds generated sync client configuration for 2025-03-01. |
| src/k8s-extension/azext_k8s_extension/vendored_sdks/v2025_03_01/_client.py | Adds generated sync client for 2025-03-01. |
| src/k8s-extension/azext_k8s_extension/vendored_sdks/v2025_03_01/init.py | Exports sync client/version for 2025-03-01. |
| src/k8s-extension/azext_k8s_extension/vendored_sdks/models.py | Re-exports models for the new 2025-03-01 profile. |
| src/k8s-extension/azext_k8s_extension/vendored_sdks/aio/_source_control_configuration_client.py | Adds 2025-03-01 profile wiring + base_url propagation in async client. |
| src/k8s-extension/azext_k8s_extension/vendored_sdks/aio/_configuration.py | Adds base_url/api_version/polling_interval to async configuration. |
| src/k8s-extension/azext_k8s_extension/vendored_sdks/_source_control_configuration_client.py | Adds 2025-03-01 profile wiring + base_url propagation in sync client. |
| src/k8s-extension/azext_k8s_extension/vendored_sdks/_configuration.py | Adds base_url/api_version/polling_interval to sync configuration. |
| src/k8s-extension/azext_k8s_extension/utils.py | Adds diagnostics collection helpers and Kubernetes error handling. |
| src/k8s-extension/azext_k8s_extension/tests/latest/test_client_configuration.py | Adds unit tests for base_url propagation in vendored clients/configs. |
| src/k8s-extension/azext_k8s_extension/tests/latest/recordings/test_k8s_extension.yaml | Updates recordings to use api-version=2025-03-01. |
| src/k8s-extension/azext_k8s_extension/partner_extensions/VirtualNodes.py | Adds VirtualNodes partner extension with AKS/VNET validation and subnet delegation. |
| src/k8s-extension/azext_k8s_extension/partner_extensions/PartnerExtensionModel.py | Extends partner extension interface to include auto_upgrade_mode. |
| src/k8s-extension/azext_k8s_extension/partner_extensions/OpenServiceMesh.py | Passes through auto_upgrade_mode in partner extension create flow. |
| src/k8s-extension/azext_k8s_extension/partner_extensions/DefaultExtension.py | Adds auto_upgrade_mode propagation for default partner extension behaviors. |
| src/k8s-extension/azext_k8s_extension/partner_extensions/DataProtectionKubernetes.py | Adds auto_upgrade_mode propagation for the extension. |
| src/k8s-extension/azext_k8s_extension/partner_extensions/Dapr.py | Adds auto_upgrade_mode propagation for create/update. |
| src/k8s-extension/azext_k8s_extension/partner_extensions/ContainerInsights.py | Adds auto_upgrade_mode propagation for create. |
| src/k8s-extension/azext_k8s_extension/partner_extensions/azuremonitormetrics/dc/defaults.py | Refactors default naming helpers for DCR/DCE/DCRA. |
| src/k8s-extension/azext_k8s_extension/partner_extensions/azuremonitormetrics/dc/dcra_api.py | Updates DCRA naming to new helper signature. |
| src/k8s-extension/azext_k8s_extension/partner_extensions/azuremonitormetrics/dc/dcr_api.py | Uses new DCR naming helper. |
| src/k8s-extension/azext_k8s_extension/partner_extensions/azuremonitormetrics/dc/dce_api.py | Uses new DCE naming helper. |
| src/k8s-extension/azext_k8s_extension/partner_extensions/azuremonitormetrics/amw/defaults.py | Changes RP locations query to be subscription-scoped; updates default region helpers. |
| src/k8s-extension/azext_k8s_extension/partner_extensions/azuremonitormetrics/amw/create.py | Passes subscription to AMW default-name/region helper. |
| src/k8s-extension/azext_k8s_extension/partner_extensions/AzureMonitorMetrics.py | Adds auto_upgrade_mode propagation. |
| src/k8s-extension/azext_k8s_extension/partner_extensions/AzureMLKubernetes.py | Adds auto_upgrade_mode propagation in create/update. |
| src/k8s-extension/azext_k8s_extension/partner_extensions/AzureDefender.py | Adds auto_upgrade_mode propagation in create. |
| src/k8s-extension/azext_k8s_extension/custom.py | Adds troubleshoot command implementation, Helm/kubectl acquisition, and auto_upgrade_mode validation. |
| src/k8s-extension/azext_k8s_extension/consts.py | Adds troubleshoot-related constants and diagnostic strings. |
| src/k8s-extension/azext_k8s_extension/commands.py | Registers the new troubleshoot command. |
| src/k8s-extension/azext_k8s_extension/_params.py | Adds CLI parameters for --auto-upgrade-mode and the troubleshoot command. |
| src/k8s-extension/azext_k8s_extension/_help.py | Adds help text/examples for az k8s-extension troubleshoot. |
| src/k8s-extension/azext_k8s_extension/init.py | Adds/adjusts type hints in command loader. |
Comment on lines
+39
to
+43
| EXTRACT_HELMEXE_FAULT_TYPE = "helm-client-extract-error" # Error extracting Helm client executable. | ||
|
|
||
| HELM_VERSION = "v3.12.2" | ||
|
|
||
| DOWNLOAD_AND_INSTALL_KUBECTL_FAULT_TYPE = "Failed to download and install kubectl" # Error downloading/installing kubectl. |
Comment on lines
+311
to
+318
| try: | ||
| # Fetching path to user directory to create the arc diagnostic folder | ||
| home_dir = os.path.expanduser("~") | ||
| filepath = os.path.join(home_dir, ".azure", base_folder_name) | ||
| # Creating Diagnostic folder and its subfolder with the given timestamp and cluster name to store all the logs | ||
| with contextlib.suppress(FileExistsError): | ||
| os.mkdir(filepath) | ||
| filepath_with_timestamp = os.path.join(filepath, folder_name) |
Comment on lines
+587
to
+595
| print("Collecting diagnostics information from the namespaces provided. This operation may take a while to complete ...\n") | ||
|
|
||
| namespaces = [ns.strip() for ns in namespace_list.split(',') if ns.strip()] | ||
|
|
||
| # Check if namespaces list is empty and throw an exception | ||
| if not namespaces: | ||
| raise RequiredArgumentMissingError( | ||
| "No valid namespaces provided. Please provide at least one namespace." | ||
| ) |
Comment on lines
+619
to
+628
| # Generate the diagnostic folder in a given location | ||
| filepath_with_timestamp, diagnostic_folder_status = ( | ||
| utils.create_folder_diagnosticlogs( | ||
| diagnostic_logs_folder_name, consts.ARC_EXT_DIAGNOSTIC_LOGS | ||
| ) | ||
| ) | ||
|
|
||
| if diagnostic_folder_status is not True: | ||
| storage_space_available = False | ||
|
|
Comment on lines
+661
to
+668
| folder_namespace, folder_namespace_status = ( | ||
| utils.create_folder_diagnostics_namespace(base_path, namespace) | ||
| ) | ||
|
|
||
| if folder_namespace_status is not True: | ||
| logger.error(f"Failed to create diagnostics folder for namespace '{namespace}'.") | ||
| collection_success = False | ||
|
|
Comment on lines
+245
to
+248
| container_log = api_instance.read_namespaced_pod_log( | ||
| name=pod_name, container=container_name, namespace=namespace | ||
| ) | ||
|
|
Comment on lines
+223
to
+229
| if pod.spec is not None: | ||
| if pod.spec.init_containers is not None: | ||
| for init_container in pod.spec.init_containers: | ||
| init_container_logs_status = collect_container_logs(api_instance, containers_folder_name, namespace, pod_name, init_container) | ||
| if not init_container_logs_status: | ||
| logger.error(f"Failed to collect logs from init container '{init_container.name}' in pod '{pod_name}'") | ||
| if pod.spec.containers is not None: |
Comment on lines
+260
to
+262
| def convert_to_pod_dict(pod) -> dict: | ||
| if pod.metadata is None or pod.status is None: | ||
| return None |
Comment on lines
+5
to
6
| from ..constants import DC_TYPE | ||
| from ..deaults import get_default_region |
Comment on lines
+142
to
+147
| c.argument('name', | ||
| options_list=['--name', '-n'], | ||
| help='Name of the Kubernetes extension') | ||
| c.argument('namespace_list', | ||
| options_list=['--namespace-list'], | ||
| help='Comma-separated list of namespaces to troubleshoot') |
Collaborator
|
k8s-extension |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This checklist is used to make sure that common guidelines for a pull request are followed.
Related command
General Guidelines
azdev style <YOUR_EXT>locally? (pip install azdevrequired)python scripts/ci/test_index.py -qlocally? (azdevrequired; see.azure-pipelines/templates/azdev_setup.ymlfor the install command untilazdev==0.2.11b1is on PyPI)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.jsonautomatically.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.