Repository navigation
[AKS] Fix #34496: az aks command invoke: Return the in-cluster command's exit code - #34498
Open
Sai Kumar Pola (alopsing) wants to merge 1 commit into
Open
Sai Kumar Pola (alopsing) wants to merge 1 commit into
Sai Kumar Pola (alopsing) wants to merge 1 commit into
Conversation
… command's exit code `az aks command invoke` and `az aks command result` printed the exit code of the command that ran in the cluster, but always exited 0 themselves. Scripts and CI pipelines could not detect a failed command without parsing the output. Exit with the in-cluster command's exit code when it is non-zero, and exit 1 when the run command itself fails (provisioning state "Failed"). Behavior with an explicit -o/--output is unchanged: the result object is still returned.
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
microsoft-github-policy-service
Bot
requested review from
FumingZhang and
elvazhu521
November 27, 2026 04:26
Contributor
|
Thank you for your contribution Sai Kumar Pola (@alopsing)! We will review the pull request and get back to you soon. |
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
A maintainer must decide whether changing the default exit statuses of both AKS commands requires an opt-in flag or breaking-change treatment because existing scripts may be affected.
No open issues 🎉
What changed in this PR
Fixes #34496 by making az aks command invoke and az aks command result report failures through their process exit status, allowing scripts and CI jobs to detect them without parsing output.
Changes:
- Propagates nonzero in-cluster exit codes and exits with status 1 when provisioning fails.
- Preserves existing behavior for successful commands, commands still running, and explicit output formats.
- Adds unit tests for failure propagation and unchanged behavior.
| File | Description |
|---|---|
src/azure-cli/azure/cli/command_modules/acs/tests/latest/test_custom.py |
Adds five tests covering exit statuses and preserved result handling. |
src/azure-cli/azure/cli/command_modules/acs/custom.py |
Updates the shared result printer to exit nonzero on command failures. |
Review effort: Balanced
Author
|
@microsoft-github-policy-service agree |
3 tasks done
Collaborator
|
/azp run |
|
Azure Pipelines: Successfully started running 3 pipeline(s). |
This branch has not been deployed
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 — ️✔️ All clear
Related command
az aks command invoke,az aks command resultDescription
Fixes #34496.
az aks command invokeprints the exit code of the command that ran inside the cluster (... with exitcode=1) but always exits 0 itself. A script or CI job that runs, for example,az aks command invoke ... --command "kubectl apply -f x.yaml"cannot tell that the command failed without parsing the output.This PR changes
_print_command_result, which bothinvokeandresultuse:Failed), exit 1 after printing the reason.-o/--outputis passed explicitly (the result object is returned as before).Two points where I would like your call:
sys.exit(code)so the in-cluster code is passed through unchanged. If you prefer anazclierrortype (which would lose the specific code), I can switch.Testing Guide
Unit tests added in
acs/tests/latest/test_custom.py(TestRunCommand):test_print_command_result_succeeded: exit code 0 returns normally.test_print_command_result_exits_with_inner_exit_code: in-cluster exit code 3 exits 3.test_print_command_result_exits_when_run_command_failed: provisioning stateFailedexits 1.test_print_command_result_in_progress: a running command returns normally.test_print_command_result_returns_object_for_explicit_output:-o jsonstill returns the object.Manual check:
I ran the new unit tests against the changed function locally. I have not run the manual check against a live cluster with this build.
History Notes
[AKS]
az aks command invoke: Return the in-cluster command's exit code so that failures are visible to scripts[AKS]
az aks command result: Return the in-cluster command's exit code so that failures are visible to scriptsThis 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. (See point 2 above.)