Repository navigation
[AKS] az aks command result: Honor --output while the command is still running - #34499
Open
Sai Kumar Pola (alopsing) wants to merge 2 commits into
Open
Sai Kumar Pola (alopsing) wants to merge 2 commits into
Sai Kumar Pola (alopsing) wants to merge 2 commits into
Conversation
…t` while the command is still running While the in-cluster command was still running (`invoke --no-wait`, or `result` before the command finished), both commands printed two lines of plain text and returned nothing, so `-o json` and the other output formats had no effect. Once the command finished, the same call returned an object. Return an object in that case too when the user passes -o/--output. It has the same keys as a finished command result, with the fields that are not known yet set to null. Without an explicit output format the text is printed as before.
|
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:38
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.
🟡 Changes recommended
Explicit JSON output with --no-wait loses the entire result, including the command ID, and a completion race can discard available exit codes, logs, and failure details.
2 open issues
What changed in this PR
This PR addresses #31157 by returning structured AKS command results while execution is still running, allowing explicit output formats to apply while preserving plain-text output when no format is specified.
Changes:
- Returns in-progress result objects from the shared helper and both command handlers.
- Shares explicit output-format detection with completed-result handling.
- Adds unit tests for structured output and unchanged default text output.
| File | Description |
|---|---|
src/azure-cli/azure/cli/command_modules/acs/tests/latest/test_custom.py |
Adds tests for in-progress results with and without explicit output formatting. |
src/azure-cli/azure/cli/command_modules/acs/custom.py |
Adds structured in-progress results and shared output-format detection. |
Review effort: Balanced
…een requests Address review feedback: - `az aks command invoke --no-wait` goes back to printing the command id as text. The CLI discards the return value of a command when --no-wait is set, so returning an object there printed nothing at all with an explicit output format. Only `az aks command result` returns an object. - If the command finishes between the two requests that `az aks command result` makes, return the complete result instead of an object with the exit code and logs set to null.
az aks command invoke/result: Honor --output while the command is still runningaz aks command result: Honor --output while the command is still running
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 resultDescription
Addresses #31157 for
az aks command result. See the note oninvoke --no-waitbelow.While the in-cluster command is still running,
az aks command resultprints two lines of plain text and returns nothing, so-o json(or any other format) has no effect. Once the command finishes, the same call returns an object and the format applies. A script that pollsaz aks command result -o jsontherefore has to handle two different kinds of output.The earlier discussion on the issue concluded that the code works as written, because the text is printed directly and never reaches the output formatter. I agree with that reading of the code. This PR changes the in-progress path of
resultso that it follows the rule_print_command_resultalready applies to finished commands: when the user passes-o/--output, return an object and let the CLI render it.Changes:
az aks command resultreturns an object for a running command when-o/--outputis passed, instead of printing. The object has the same keys as a finished result (id,provisioningState,startedAt,finishedAt,exitCode,logs,reason); the ones not known yet arenull. The existing table transformer already handles this shape.resultmakes, the complete result is returned._output_format_specified, so both paths share it.-o/--output, the printed text is unchanged.Output of
az aks command result -o jsonfor a running command, before:After:
Not changed:
az aks command invoke --no-waitThe issue also reports this command. It still prints the command id as text, whatever
-osays.invokeis registered withsupports_no_wait=True, and the CLI core discards the return value of such a command when--no-waitis set, so there is no object to render. The first commit of this PR got this wrong and would have printed nothing; the second commit restores the text. Honoring-othere needs a change to how the command is registered (declaring--no-waitin the module instead ofsupports_no_wait). I can do that in this PR or a follow-up if you want it.One point where I would like your call: a script that passes
-o jsontoresulttoday and reads the printed text for a running command will see JSON instead. I think that is what such a script asked for, but tell me if you want this handled differently.This PR is independent of #34498 and merges cleanly with it.
Testing Guide
Unit tests added in
acs/tests/latest/test_custom.py(TestRunCommand):test_command_result_in_progress_returns_object_for_explicit_output: a running command with--outputreturns the object.test_command_result_returns_result_finished_between_requests: a command that finishes between the two requests returns the complete result.test_command_result_in_progress_prints_without_explicit_output: a running command without--outputprints the text and returns nothing, as before.Manual check:
I ran the new unit tests against the changed functions locally. I have not run the manual check against a live cluster with this build.
History Notes
[AKS]
az aks command result: Honor--outputwhile the command is still runningThis 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.