6868 CONST_AZURE_SERVICE_MESH_MODE_ISTIO ,
6969 CONST_MANAGED_CLUSTER_SKU_TIER_PREMIUM ,
7070)
71-
71+ from azure . cli . command_modules . acs . _polling import RunCommandLocationPolling
7272from azure .cli .command_modules .acs ._helpers import get_snapshot_by_snapshot_id , check_is_private_link_cluster
7373from azure .cli .command_modules .acs ._resourcegroup import get_rg_location
7474from azure .cli .command_modules .acs ._validators import extract_comma_separated_string
9595from azure .cli .core .commands import LongRunningOperation
9696from azure .cli .core .commands .client_factory import get_subscription_id
9797from azure .cli .core .profiles import ResourceType
98+ from azure .mgmt .core .polling .arm_polling import ARMPolling
9899from azure .cli .core .util import in_cloud_console , sdk_no_wait
99100from azure .core .exceptions import ResourceNotFoundError as ResourceNotFoundErrorAzCore
100101from azure .mgmt .containerservice .models import KubernetesSupportPlan
102+ from humanfriendly .terminal .spinners import Spinner
101103from knack .log import get_logger
102104from knack .prompting import NoTTYException , prompt_y_n
103105from knack .util import CLIError
@@ -2034,6 +2036,7 @@ def aks_runcommand(cmd, client, resource_group_name, name, command_string="", co
20342036
20352037 if not command_string :
20362038 raise ValidationError ('Command cannot be empty.' )
2039+
20372040 RunCommandRequest = cmd .get_models ('RunCommandRequest' , resource_type = ResourceType .MGMT_CONTAINERSERVICE ,
20382041 operation_group = 'managed_clusters' )
20392042 request_payload = RunCommandRequest (command = command_string )
@@ -2046,8 +2049,15 @@ def aks_runcommand(cmd, client, resource_group_name, name, command_string="", co
20462049 request_payload .cluster_token = _get_dataplane_aad_token (
20472050 cmd .cli_ctx , "6dae42f8-4368-4678-94ff-3960e28e3630" )
20482051
2052+ polling_interval = 5
2053+ retry_total = 0
2054+
20492055 command_result_poller = sdk_no_wait (
2050- no_wait , client .begin_run_command , resource_group_name , name , request_payload , polling_interval = 5 , retry_total = 0
2056+ no_wait , client .begin_run_command , resource_group_name , name , request_payload ,
2057+ # NOTE: Note sure if retry_total is used in ARMPolling
2058+ polling = ARMPolling (polling_interval , lro_options = {"final-state-via" : "location" }, lro_algorithms = [RunCommandLocationPolling ()], retry_total = retry_total ),
2059+ polling_interval = polling_interval ,
2060+ retry_total = retry_total
20512061 )
20522062 if no_wait :
20532063 # pylint: disable=protected-access
@@ -2058,7 +2068,22 @@ def aks_runcommand(cmd, client, resource_group_name, name, command_string="", co
20582068 command_id = command_id_regex .findall (command_result_polling_url )[0 ]
20592069 _aks_command_result_in_progess_helper (client , resource_group_name , name , command_id )
20602070 return
2061- return _print_command_result (cmd .cli_ctx , command_result_poller .result (300 ))
2071+
2072+ spinner = Spinner (label = 'Running' , stream = sys .stderr , hide_cursor = False )
2073+ progress_controller = cmd .cli_ctx .get_progress_controller (det = False , spinner = spinner )
2074+
2075+ now = datetime .datetime .now ()
2076+ progress_controller .begin ()
2077+ while not command_result_poller .done ():
2078+ if datetime .datetime .now () - now >= datetime .timedelta (seconds = 300 ):
2079+ break
2080+
2081+ progress_controller .add (message = command_result_poller .status ())
2082+ progress_controller .update ()
2083+ time .sleep (0.5 )
2084+
2085+ progress_controller .end ()
2086+ return _print_command_result (cmd .cli_ctx , command_result_poller .result (timeout = 0 ))
20622087
20632088
20642089def aks_command_result (cmd , client , resource_group_name , name , command_id = "" ):
@@ -2115,7 +2140,7 @@ def _print_command_result(cli_ctx, commandResult):
21152140 return
21162141
21172142 # *-ing state
2118- print (f"{ colorama .Fore .BLUE } command is in { commandResult .provisioning_state } state{ colorama .Style .RESET_ALL } " )
2143+ print (f"{ colorama .Fore .BLUE } command (id: { commandResult . id } ) is in { commandResult .provisioning_state } state{ colorama .Style .RESET_ALL } " )
21192144 return
21202145
21212146
0 commit comments