Repository navigation
[aks-preview] Fix executable lookup and kubeconfig conversion - #10606
Open
FumingZhang wants to merge 2 commits into
Open
FumingZhang wants to merge 2 commits into
FumingZhang wants to merge 2 commits into
Conversation
Use the CLI core safe executable resolver for bare tool names while preserving explicit-path validation and directory symlink semantics. Convert only the selected kubeconfig file and skip stdout-only conversion. Release aks-preview 22.0.0b18 with a minimum CLI core version of 2.93.0. Add focused lookup, output-file and compatibility regressions, and update release/dependency documentation. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Collaborator
|
/azp run |
|
Azure Pipelines: Successfully started running 2 pipeline(s). |
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Resolving the final executable symlink changes the invocation basename, which can break command dispatch for an explicit kubectl symlink to a multicall executable.
1 open issue
What changed in this PR
This PR hardens AKS tool lookup and makes az aks get-credentials convert only the selected kubeconfig, without changing the working directory or unrelated files.
Changes:
- Delegate bare executable lookup to CLI core while retaining explicit-path handling.
- Pass an explicit kubeconfig to
kubelogin, skip conversion for stdout output, and add regression tests. - Release
22.0.0b18with a minimum Azure CLI version of2.93.0.
| File | Description |
|---|---|
src/aks-preview/setup.py |
Bumps the extension version to 22.0.0b18. |
src/aks-preview/README.rst |
Updates the CLI dependency table. |
src/aks-preview/HISTORY.rst |
Documents fixes and the new CLI minimum. |
src/aks-preview/azext_aks_preview/tests/latest/test_helpers.py |
Tests executable lookup and symlink handling. |
src/aks-preview/azext_aks_preview/tests/latest/test_custom.py |
Tests selected-file conversion, stdout output, and warnings. |
src/aks-preview/azext_aks_preview/custom.py |
Targets kubeconfig conversion explicitly and removes CWD changes. |
src/aks-preview/azext_aks_preview/azext_metadata.json |
Requires Azure CLI 2.93.0 or later. |
src/aks-preview/azext_aks_preview/_helpers.py |
Uses CLI core lookup and revises explicit-path resolution. |
Review effort: Balanced
| if os.path.isfile(bin_path) and os.access(bin_path, os.X_OK): | ||
| return bin_path | ||
| for executable in binaries: | ||
| bin_path = os.path.realpath(executable) |
Resolve the parent directory without dereferencing the final executable alias so basename-dispatched tools keep their invocation name. Retain directory-symlink and dot-dot path handling and executable validation. Cover absolute, relative and symlink-parent explicit paths in the existing resolver tests. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

🤖 PR Validation —⚠️ Review suggested
This PR adds warning or check suppressions. Fix the underlying warning where possible and justify each remaining suppression in a code comment or the PR description.
4 added suppressions
src/aks-preview/azext_aks_preview/tests/latest/test_custom.py@unittest.skipIf(os.name == "nt", "Requires a POSIX executable script and directory symlinks")src/aks-preview/azext_aks_preview/tests/latest/test_helpers.py@unittest.skipIf(os.name == "nt", "Requires directory symlinks")src/aks-preview/azext_aks_preview/tests/latest/test_helpers.py@unittest.skipIf(os.name == "nt", "Requires file and directory symlinks")src/aks-preview/azext_aks_preview/tests/latest/test_helpers.py@unittest.skipIf(os.name == "nt", "Requires file symlinks")This checklist is used to make sure that common guidelines for a pull request are followed.
Related command
az aks get-credentials,az aks kollect,az aks kanalyze,az aks bastion tunnelget_safe_executable_path; retain explicit-path validation and the final executable alias name, preserving directory-symlink/..semantics.--kubeconfig, without changing CWD or touching an inherited, unrelated kubeconfig. Skip conversion for--file -and preserve existing warnings.22.0.0b18withazext.minCliCoreVersionraised from2.85.0to2.93.0, and update the dependency table/history. CLI 2.92 introduced the helper; 2.93 includes the CWD-linked-executable and path-verification safeguards required here.Validation on Linux with repository sources on
PYTHONPATH: 66 tests and 54 subtests passed. The selected regressions failed before the implementation changes.Using CI-matching linters in a temporary local environment:
.ci-10606-alias-20261120/bin/python -m pylint --rcfile=pylintrc --persistent=no src/aks-preview/azext_aks_preview/_helpers.py.ci-10606-alias-20261120/bin/python -m flake8 --append-config=.flake8 src/aks-preview/azext_aks_preview/_helpers.pypython scripts/ci/test_index.py TestIndex.test_format_version TestIndex.test_format_extensions_key TestIndex.test_format_extensions_value TestIndex.test_extension_filenames -qgit diff --cached --checkWheel build and embedded metadata checks passed:
aks_preview-22.0.0b18-py2.py3-none-any.whlcontains the2.93.0minimum; CLI compatibility checks reject2.92.0and accept2.93.0. Python compilation and changed-line pycodestyle also passed.Native Windows/macOS and live Azure tests were not run. Existing Git hooks could not activate their expected azdev environment; no hooks were bypassed or changed. The full index checksum/download suite was not run because the index is unchanged. No shared CLI documentation or other PR branches were modified.
General Guidelines
azdev style <YOUR_EXT>locally? (pip install azdevrequired)python scripts/ci/test_index.py -qlocally? (pip install azdevrequired)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.