[AKS] az aks command invoke: Add support for --no-wait#22813
[AKS] az aks command invoke: Add support for --no-wait#22813zhoxing-ms merged 5 commits intoAzure:devfrom
az aks command invoke: Add support for --no-wait#22813Conversation
|
AKS |
| command_id_regex = re.compile(r'commandResults\/(\w*)\?') | ||
| command_id = command_id_regex.findall(command_result_polling_url)[0] | ||
| logger.warning("command id: %s", command_id) | ||
| return _print_command_result(cmd.cli_ctx, command_result_poller.result(300)) |
There was a problem hiding this comment.
can we condition this on no_wait parameter?
if no_wait==true
print command id
instruct how to fetch result with "az aks command result"
else
...
| f"with exitcode={commandResult.exit_code}{colorama.Style.RESET_ALL}") | ||
| print(commandResult.logs) | ||
| return | ||
| if commandResult: |
There was a problem hiding this comment.
For the situation where the command is running, the HTTP status code of the response is 202, at this time the commandResult will be parsed as None (see SDK), resulting in the following exception
| print(f"{colorama.Fore.BLUE}command is in {commandResult.provisioning_state} state{colorama.Style.RESET_ALL}") | ||
| return |
There was a problem hiding this comment.
Removed a misleading colon (:).
FumingZhang
left a comment
There was a problem hiding this comment.
For those commands executed without the additional --no-wait option, the results are the same as before
For commands with the --no-wait option, the results are as follows
| def _aks_command_result_in_progess_helper(client, resource_group_name, name, command_id): | ||
| # pylint: disable=unused-argument | ||
| def command_result_direct_response_handler(pipeline_response, *args, **kwargs): | ||
| deserialized_data = pipeline_response.context.get("deserialized_data", {}) | ||
| if deserialized_data: | ||
| provisioning_state = deserialized_data.get("properties", {}).get("provisioningState", None) | ||
| started_at = deserialized_data.get("properties", {}).get("startedAt", None) | ||
| print(f"command id: {command_id}, started at: {started_at}, status: {provisioning_state}") | ||
| print( | ||
| f"Please use command \"az aks command result -g {resource_group_name} -n {name} -i {command_id}\" " | ||
| "to get the future execution result" | ||
| ) | ||
| else: | ||
| print(f"failed to fetch command result for command id: {command_id}") | ||
| client.get_command_result(resource_group_name, name, command_id, cls=command_result_direct_response_handler) | ||
| return |
There was a problem hiding this comment.
Since it is declared in swagger that the 202 HTTP status code is returned for the command in running state and no response parsing is performed, the response is manually parsed here in a relatively ugly way.
| if commandResult is None: | ||
| _aks_command_result_in_progess_helper(client, resource_group_name, name, command_id) | ||
| return |
There was a problem hiding this comment.
The SDK will not parse the response result of the query corresponding to the command that is still in running state.
| command_result_polling_url = command_result_poller.polling_method()._initial_response.http_response.headers[ | ||
| "location" | ||
| ] | ||
| command_id_regex = re.compile(r"commandResults\/(\w*)\?") | ||
| command_id = command_id_regex.findall(command_result_polling_url)[0] |
There was a problem hiding this comment.
The initial response content of the request is empty. The API path to query command result can only be obtained through the location field in the header of the response.
aks command commandsaz aks command invoke: Add support for --no-wait







Related command
az aks command invokeaz aks command resultDescription
--no-waitinaz aks command invokeaz aks command invokeTesting Guide
History Notes
[Component Name 1] BREAKING CHANGE:
az command a: Make some customer-facing breaking change[Component Name 2]
az command b: Add some customer-facing featureThis 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.