Repository navigation
[AKS] Fix #34091: az aks get-credentials: Fix kubelogin conversion for explicit kubeconfig paths - #34104
Conversation
…sion for explicit kubeconfig paths AI-generated by X Engineering Agent via Azure AI Foundry. Foundry-Job: 63d5031c5731ded4cf8b3593b8e493b3b2ed1abc96581152b52b8dc23740b9dc
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Resolve the critical risk of launching an unintended kubelogin executable instead of the resolved PATH executable.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
What changed in this PR
Fixes az aks get-credentials kubelogin conversion when an explicit kubeconfig path is used.
Changes:
- Passes the selected kubeconfig path to kubelogin.
- Adds regression coverage for conversion, path handling, failures, and security cases.
| File | Summary |
|---|---|
src/azure-cli/azure/cli/command_modules/acs/tests/latest/test_custom.py |
Adds focused regression coverage. |
src/azure-cli/azure/cli/command_modules/acs/custom.py |
Updates kubelogin conversion invocation. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| if path != "-" and uses_kubelogin_devicecode(kubeconfig): | ||
| if which("kubelogin"): | ||
| try: | ||
| # Run kubelogin convert-kubeconfig -l azurecli | ||
| # Select the merged file without changing how relative paths are resolved. | ||
| subprocess.run( | ||
| ["kubelogin", "convert-kubeconfig", "-l", "azurecli"], | ||
| cwd=os.path.dirname(path), | ||
| ["kubelogin", "convert-kubeconfig", "-l", "azurecli", "--kubeconfig", path], |
There was a problem hiding this comment.
Aditya Pujara (@a0x1ab) Please take a look at this unresolved executable-resolution issue. The duplicate thread has been removed; please retain the resolved which("kubelogin") result, normalize it with os.path.abspath(), and use that absolute path as argv[0].
|
/azp run |
|
Azure Pipelines: Successfully started running 3 pipeline(s). |
|
/azp run |
|
Azure Pipelines: Successfully started running 3 pipeline(s). |
|
don't forget to resolve the merge conflict too Aditya Pujara (@a0x1ab) |
|
Please fix CI issues |
|
There's still merge conflict Aditya Pujara (@a0x1ab) |
…031c5731 Resolved import-only conflicts in: - src/azure-cli/azure/cli/command_modules/acs/tests/latest/test_custom.py
|
/azp run |
|
Azure Pipelines: Successfully started running 3 pipeline(s). |
Live test results —
|
|
Azure/azure-cli#34099 and Azure/azure-cli#34104 implement the same runtime fix; only comments and tests differ. I suggest consolidating into #34099 for its broader test coverage, carrying over useful cases from #34104. Before merging, please also address the executable-resolution feedback: invoke the absolute path returned by |
There was a problem hiding this comment.
Review
Upstream CI passed (52 checks), and the Agent live test passed for head 63ce4617c2d7b65bdaf31d0633bbd077b17c665c. One confirmed security finding remains.
Confirmed code finding
Executable selection (high): src/azure-cli/azure/cli/command_modules/acs/custom.py:2069 still passes the bare kubelogin name as argv[0] after discarding which("kubelogin"). On Windows, CreateProcess can select a current-directory executable before the executable found on PATH. Removing cwd also changes that search directory to the caller's working directory. Save the lookup result, normalize it with os.path.abspath, and pass that absolute executable as argv[0]. This addresses the outstanding human feedback.
Update src/azure-cli/azure/cli/command_modules/acs/tests/latest/test_custom.py to assert the resolved executable path, including a relative PATH result and a Windows current-directory shadowing case. Existing subprocess-mock assertions require the bare name, and the real-executable tests skip Windows, so they do not catch this risk. Rerun the focused AksGetCredentialsTest cases through the approved validation workflow.
Test validation
- Live test: Passed. Workflow run
- Regression coverage: For
acs: 1 focused test file(s) changed. Scenario coverage is unverified; review the issue's required conditions, test setup, and assertions before approval. No linked issue was found in the PR timeline; inspect the source issue and its required scenario manually.
The source issue #34091 requires conversion of the selected kubeconfig from devicecode to azurecli mode. The changed tests cover relative/absolute/spaced paths, KUBECONFIG selection, stdout bypass, missing converter and subprocess failure; their POSIX subprocess fixture asserts the converted file and unrelated-file preservation. No updated recording or actual Windows executable-selection coverage is included; the live workflow result does not establish that missing Windows scenario.
Risk assessment
65/100 - High - High confidence
- Evidence: The changed subprocess call uses an unresolved executable name on a credential-handling path; Windows coverage is absent. CI and POSIX conversion coverage reduce uncertainty for the path-selection fix, not the executable-selection issue.
- Scope: Two files in
acs, one production file, with focused tests. - Required review: Owning AKS squad and security review before merge; no approval is requested until executable resolution and its regression coverage are addressed.
Posted by x-engineering-agent (Reviewer)
X Engineering Agent Report⏳ In progress — X Engineering Agent is reviewing this PR at Handed to maintainersI could not verify this PR's durable Foundry publication and managed head. I cannot safely apply the feedback at #34104 (comment); leaving this PR for manual follow-up. Posted by x-engineering-agent (Reviewer) Review — Comments The explicit kubeconfig selection addresses #34091's empty-directory failure, but the executable-selection feedback remains unresolved on head Upstream CI52/52 checks passed in this round's snapshot; no failed or pending upstream checks. Test validation
The tests exercise I manually inspected #34091: removing Confirmed finding — [P1] Execute the resolved absolute kubelogin path.
Keep the lookup result, normalize it with This confirms both human feedback and Copilot reviewer feedback; neither is resolved by the current head. No other correctness finding was confirmed by this review. Next action: Maintainer follow-up is required under the existing provenance handoff. No implementation job was queued because durable publication/managed-head provenance remains unverified. The review request is retained; this does not approve the PR. Focused verification after correction: Run Risk assessment — 16/100 · Low · High confidenceThe Low rating is driven by public CLI behavior.
Posted by x-engineering-agent (Reviewer) Live test — Passed (9/9)PASS Selectors: Changed test files runWorkflow run: https://github.com/Azure/issue-sentinel/actions/runs/38727066296 Last 80 lines of azdev outputPosted by x-engineering-agent (Tester) |

🤖 PR Validation — ️✔️ All clear
Related command
az aks get-credentialsDescription
Fixes #34091.
Implemented by X Engineering Agent using Azure AI Foundry. This is an AI-generated change, published by the configured operator.
Testing Guide
az aks get-credentials.src/azure-cli/azure/cli/command_modules/acs/tests/latest/test_custom.py.History Notes
[AKS]
az aks get-credentials: Fix kubelogin conversion for explicit 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.