Repository navigation
[AKS] Fix #34091: az aks get-credentials: Fix kubelogin conversion for custom kubeconfig paths - #34442
Merged
xuming-ms merged 7 commits intoNov 23, 2026
Conversation
Pass the merged kubeconfig explicitly to kubelogin without changing its working directory. Reuse the resolved executable, skip stdout-only requests and preserve conversion failure warnings. Add regression coverage for file selection, stdout and real subprocess conversion without touching unrelated kubeconfig files. Fixes Azure#34091. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
|
Hi FumingZhang, |
Collaborator
|
/azp run |
|
Azure Pipelines: Successfully started running 3 pipeline(s). |
3 tasks done
Resolve the conversion target after credential merging so paths containing a directory symlink followed by dot-dot still select the file that was written. Preserve the existing rejection of symlink kubeconfig files. Cover relative, absolute and KUBECONFIG-provided paths and verify unrelated files remain unchanged. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Use the shared safe executable resolver for kubeconfig conversion and invoke its result directly. Avoid lexical normalization changing which executable is selected when PATH contains directory symlinks followed by dot-dot. Cover executable path identity and working-directory decoys while preserving kubeconfig selection, symlink-file protection and conversion warnings. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This reverts commit 5bd766c. Keep executable lookup changes scoped to Azure#34445. Preserve the kubeconfig output-path fixes and directory symlink regression coverage in this PR. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Integrate the merged executable lookup fixes while keeping explicit kubeconfig selection, stdout behavior and directory symlink handling. Retain both upstream executable regression suites and the kubeconfig path tests. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are identified for the change that directs kubelogin conversion to the selected kubeconfig.
No open issues 🎉
What changed in this PR
Fixes az aks get-credentials so automatic kubelogin conversion targets the selected kubeconfig, including custom relative paths, rather than relying on a working-directory change.
Changes:
- Pass the resolved output path explicitly through
--kubeconfig, preserving directory-symlink behavior. - Skip conversion for stdout output and retain warnings for missing kubelogin and expected process failures.
- Add regression coverage for file selection, symlinks, stdout behavior, and conversion failures while preserving executable-safety tests.
| File | Description |
|---|---|
src/azure-cli/azure/cli/command_modules/acs/tests/latest/test_custom.py |
Adds conversion regressions and updates expected subprocess arguments. |
src/azure-cli/azure/cli/command_modules/acs/custom.py |
Selects the kubeconfig explicitly, skips stdout conversion, and narrows launch-error handling. |
Review effort: Balanced
Contributor
|
There's a breaking-change error showing up here, I have rebased from dev |
xuming-ms
approved these changes
Nov 23, 2026
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.
3 added suppressions
src/azure-cli/azure/cli/command_modules/acs/tests/latest/test_custom.py@unittest.skipIf(os.name == "nt", "Requires a POSIX executable script.")src/azure-cli/azure/cli/command_modules/acs/tests/latest/test_custom.py@unittest.skipIf(os.name == "nt", "Requires directory symlinks.")src/azure-cli/azure/cli/command_modules/acs/tests/latest/test_custom.py@unittest.skipIf(os.name == "nt", "Requires file symlinks.")Related command
az aks get-credentialsDescription
Fixes #34091.
The automatic kubelogin conversion passes
os.path.dirname(path)as its working directory. For a bare relative filename such as--file config, this is an empty string, causing[Errno 2] No such file or directory: ''before kubelogin starts. Changing directories also does not select the kubeconfig to convert, so a custom output file can remain in device-code mode while another kubeconfig is modified.--kubeconfigafter merging, preserving directory-symlink/..semantics and the existing refusal of symlink kubeconfig files.az aks get-credentials: Fix kubelogin executable lookup #34445 and [AKS]az aks: Fix external tool invocation #34446; this PR adds kubeconfig file selection and preserves their regression coverage.--file -, preserving stdout-only behavior without touching other kubeconfig files.Testing Guide
Merged-dev regressions: 80 passed, 3 Windows-only skipped; 243 subtests passed. Executed with repository sources on PYTHONPATH and isolated temporary configuration.
/usr/bin/python -m pytest -q --tb=short -p no:cacheprovider src/azure-cli/azure/cli/command_modules/acs/tests/latest/test_custom.py src/azure-cli/azure/cli/command_modules/acs/tests/latest/test_aks_install_desktop.py src/azure-cli-core/azure/cli/core/tests/test_util.py::TestSafeExecutablePath -k 'install_desktop or AksExternalToolsTest or AksGetCredentialsTest or AksGetCredentialsExecutableTest or TestSafeExecutablePath'Pylint 4.1.4 with the repository configuration: passed, 10.00/10. Production flake8, source compilation and whitespace checks passed.
The merge retains all three credential/executable/external-tool regression classes and preserves the upstream safe resolver. Native Windows and live Azure checks are not covered by these unit tests. Existing hook bootstrap could not activate its expected virtual environment; checks were run directly.
History Notes
[AKS]
az aks get-credentials: Fix automatic kubelogin conversion for custom kubeconfig pathsThis checklist is used to make sure that common guidelines for a pull request are followed.
The PR title and description has followed the guideline in Submitting Pull Requests.
I adhere to the Command Guidelines.
I adhere to the Error Handling Guidelines.