Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AKS] az aks command invoke: Add progress spinner #30274

Open
wants to merge 7 commits into
base: dev
Choose a base branch
from

Conversation

CustardTart32
Copy link

@CustardTart32 CustardTart32 commented Nov 7, 2024

Related command
az aks command invoke

Description
This PR adds a spinner and progress message to the az aks command invoke CLI command, which can take several minutes to complete.

Testing Guide

History Notes

[AKS] az aks command invoke: Add progress spinner


This checklist is used to make sure that common guidelines for a pull request are followed.

Copy link

azure-client-tools-bot-prd bot commented Nov 7, 2024

️✔️AzureCLI-FullTest
️✔️acr
️✔️2020-09-01-hybrid
️✔️3.12
️✔️3.9
️✔️latest
️✔️3.12
️✔️3.9
️✔️acs
️✔️2020-09-01-hybrid
️✔️3.12
️✔️3.9
️✔️latest
️✔️3.12
️✔️3.9
️✔️advisor
️✔️latest
️✔️3.12
️✔️3.9
️✔️ams
️✔️latest
️✔️3.12
️✔️3.9
️✔️apim
️✔️latest
️✔️3.12
️✔️3.9
️✔️appconfig
️✔️latest
️✔️3.12
️✔️3.9
️✔️appservice
️✔️latest
️✔️3.12
️✔️3.9
️✔️aro
️✔️latest
️✔️3.12
️✔️3.9
️✔️backup
️✔️latest
️✔️3.12
️✔️3.9
️✔️batch
️✔️latest
️✔️3.12
️✔️3.9
️✔️batchai
️✔️latest
️✔️3.12
️✔️3.9
️✔️billing
️✔️latest
️✔️3.12
️✔️3.9
️✔️botservice
️✔️latest
️✔️3.12
️✔️3.9
️✔️cdn
️✔️latest
️✔️3.12
️✔️3.9
️✔️cloud
️✔️latest
️✔️3.12
️✔️3.9
️✔️cognitiveservices
️✔️latest
️✔️3.12
️✔️3.9
️✔️compute_recommender
️✔️latest
️✔️3.12
️✔️3.9
️✔️computefleet
️✔️latest
️✔️3.12
️✔️3.9
️✔️config
️✔️latest
️✔️3.12
️✔️3.9
️✔️configure
️✔️latest
️✔️3.12
️✔️3.9
️✔️consumption
️✔️latest
️✔️3.12
️✔️3.9
️✔️container
️✔️latest
️✔️3.12
️✔️3.9
️✔️containerapp
️✔️latest
️✔️3.12
️✔️3.9
️✔️core
️✔️2018-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️2019-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️2020-09-01-hybrid
️✔️3.12
️✔️3.9
️✔️latest
️✔️3.12
️✔️3.9
️✔️cosmosdb
️✔️latest
️✔️3.12
️✔️3.9
️✔️databoxedge
️✔️2019-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️2020-09-01-hybrid
️✔️3.12
️✔️3.9
️✔️latest
️✔️3.12
️✔️3.9
️✔️dls
️✔️latest
️✔️3.12
️✔️3.9
️✔️dms
️✔️latest
️✔️3.12
️✔️3.9
️✔️eventgrid
️✔️latest
️✔️3.12
️✔️3.9
️✔️eventhubs
️✔️latest
️✔️3.12
️✔️3.9
️✔️feedback
️✔️latest
️✔️3.12
️✔️3.9
️✔️find
️✔️latest
️✔️3.12
️✔️3.9
️✔️hdinsight
️✔️latest
️✔️3.12
️✔️3.9
️✔️identity
️✔️latest
️✔️3.12
️✔️3.9
️✔️iot
️✔️2019-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️2020-09-01-hybrid
️✔️3.12
️✔️3.9
️✔️latest
️✔️3.12
️✔️3.9
️✔️keyvault
️✔️2018-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️2020-09-01-hybrid
️✔️3.12
️✔️3.9
️✔️latest
️✔️3.12
️✔️3.9
️✔️lab
️✔️latest
️✔️3.12
️✔️3.9
️✔️managedservices
️✔️latest
️✔️3.12
️✔️3.9
️✔️maps
️✔️latest
️✔️3.12
️✔️3.9
️✔️marketplaceordering
️✔️latest
️✔️3.12
️✔️3.9
️✔️monitor
️✔️latest
️✔️3.12
️✔️3.9
️✔️mysql
️✔️latest
️✔️3.12
️✔️3.9
️✔️netappfiles
️✔️latest
️✔️3.12
️✔️3.9
️✔️network
️✔️2018-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️latest
️✔️3.12
️✔️3.9
️✔️policyinsights
️✔️latest
️✔️3.12
️✔️3.9
️✔️privatedns
️✔️latest
️✔️3.12
️✔️3.9
️✔️profile
️✔️latest
️✔️3.12
️✔️3.9
️✔️rdbms
️✔️latest
️✔️3.12
️✔️3.9
️✔️redis
️✔️latest
️✔️3.12
️✔️3.9
️✔️relay
️✔️latest
️✔️3.12
️✔️3.9
️✔️resource
️✔️2018-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️2019-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️latest
️✔️3.12
️✔️3.9
️✔️role
️✔️latest
️✔️3.12
️✔️3.9
️✔️search
️✔️latest
️✔️3.12
️✔️3.9
️✔️security
️✔️latest
️✔️3.12
️✔️3.9
️✔️servicebus
️✔️latest
️✔️3.12
️✔️3.9
️✔️serviceconnector
️✔️latest
️✔️3.12
️✔️3.9
️✔️servicefabric
️✔️latest
️✔️3.12
️✔️3.9
️✔️signalr
️✔️latest
️✔️3.12
️✔️3.9
️✔️sql
️✔️latest
️✔️3.12
️✔️3.9
️✔️sqlvm
️✔️latest
️✔️3.12
️✔️3.9
️✔️storage
️✔️2018-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️2019-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️2020-09-01-hybrid
️✔️3.12
️✔️3.9
️✔️latest
️✔️3.12
️✔️3.9
️✔️synapse
️✔️latest
️✔️3.12
️✔️3.9
️✔️telemetry
️✔️2018-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️2019-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️2020-09-01-hybrid
️✔️3.12
️✔️3.9
️✔️latest
️✔️3.12
️✔️3.9
️✔️util
️✔️latest
️✔️3.12
️✔️3.9
️✔️vm
️✔️2018-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️2019-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️2020-09-01-hybrid
️✔️3.12
️✔️3.9
️✔️latest
️✔️3.12
️✔️3.9

Copy link

Hi @CustardTart32,
Since the current milestone time is less than 7 days, this pr will be reviewed in the next milestone.

Copy link

azure-client-tools-bot-prd bot commented Nov 7, 2024

️✔️AzureCLI-BreakingChangeTest
️✔️Non Breaking Changes

@yonzhan
Copy link
Collaborator

yonzhan commented Nov 7, 2024

Thank you for your contribution! We will review the pull request and get back to you soon.

@CustardTart32
Copy link
Author

@microsoft-github-policy-service agree company="Microsoft"

Copy link
Member

@FumingZhang FumingZhang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Queued live test to validate the change, test passed!

  • test_aks_run_command

@@ -2058,7 +2102,8 @@ def aks_runcommand(cmd, client, resource_group_name, name, command_string="", co
command_id = command_id_regex.findall(command_result_polling_url)[0]
_aks_command_result_in_progess_helper(client, resource_group_name, name, command_id)
return
return _print_command_result(cmd.cli_ctx, command_result_poller.result(300))

return LongRunningOperation(cmd.cli_ctx, progress_bar=PollerProgressBar(cmd.cli_ctx, command_result_poller))(command_result_poller)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems this would change the command output, and this might be regarded as a breaking change.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be great if you could add an example in the description to show the difference before and after the change.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, just checked and this would change the output format. I'll see if I can align the two.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before:
image

After:
image

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, I've added a new commit to align the output formats.

After:
image

src/azure-cli-core/azure/cli/core/commands/progress.py Outdated Show resolved Hide resolved
@CustardTart32 CustardTart32 force-pushed the czhong/feat/run-command-status-poller branch from 12712f0 to 67b9c42 Compare November 7, 2024 09:26
@CustardTart32 CustardTart32 force-pushed the czhong/feat/run-command-status-poller branch 2 times, most recently from 75d5f38 to 7bbfe83 Compare November 8, 2024 03:17
@yanzhudd
Copy link
Contributor

yanzhudd commented Nov 8, 2024

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@yanzhudd
Copy link
Contributor

yanzhudd commented Nov 8, 2024

please fix the title with impacted command/parameter, e.g.,
[AKS] az xxx: the function of this PR

@CustardTart32 CustardTart32 force-pushed the czhong/feat/run-command-status-poller branch from d4f839d to d2f3cd6 Compare November 8, 2024 08:42
@yanzhudd
Copy link
Contributor

yanzhudd commented Nov 8, 2024

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@yanzhudd
Copy link
Contributor

please add tests for the change to verify if it meets your expectations

Comment on lines 2083 to 2086
progress_bar.end()
return _print_command_result(cmd.cli_ctx, command_result_poller.result())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so if the operation is not completed within 300 seconds, the progress bar will end, but the polling here will continue (until it times out on the server side?)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I understand, if the operation is not completed in 300s, the failure message will be logged and the python process (including the poller) will be terminated.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did a simple test based on your branch, the following command is executed and does not terminate after 5 minutes. After 5 minutes, only the progress bar is no longer displayed, and the command finally returns in 10 minutes.

az aks command invoke -g xxx -n xxx -c "sleep 600 && echo hello"



class RunCommandLocationPolling(LocationPolling):
"""Extends LocationPolling but uses the body content instead of the status code for the status"""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May I ask why you want to inherit your own Poller and use this special status logic?

Copy link
Author

@CustardTart32 CustardTart32 Nov 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically, I want the message in the progress bar to be dynamically generated based on the poller HTTP response. LocationPolling basically checks the status code and returns a hardcoded value of InProgress if HTTP status 201/202 hence why we have to extend the class.

BodyContentPolling only supports PUT/PATCH methods which is not applicable here and neither does OperationResourcePolling.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Running is the status field from the API response.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Git it, thanks~

zhoxing-ms
zhoxing-ms previously approved these changes Nov 11, 2024
@haitch
Copy link
Member

haitch commented Nov 11, 2024

Thanks @CustardTart32 , this is first step on AKS to show more details on long running operations, to improve customer experience. here I capture a gif using asciinema, you can see the Starting, Initing, Running state transitioning.

Later we are going to apply this to az aks create, az aks upgrade, which would usually cost 3-4 minutes, and utlimately az aks upgrade, az aks nodepool upgrade which could last for couple hours depend on the number of VMs.
demo

@yanzhudd
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@CustardTart32 CustardTart32 force-pushed the czhong/feat/run-command-status-poller branch from dbe98d0 to 2c2b08e Compare November 12, 2024 02:58
@yanzhudd
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@yanzhudd
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@zhoxing-ms
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

Comment on lines +2075 to +2086
now = datetime.datetime.now()
progress_controller.begin()
while not command_result_poller.done():
if datetime.datetime.now() - now >= datetime.timedelta(seconds=300):
break

progress_controller.add(message=command_result_poller.status())
progress_controller.update()
time.sleep(0.5)

progress_controller.end()
return _print_command_result(cmd.cli_ctx, command_result_poller.result())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#30274 (comment)
My suggestion is to either share this timeout with both the progress bar and the poller, or not set a timeout.

@yanzhudd
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AKS az aks/acs/openshift Auto-Assign Auto assign by bot
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants