-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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 support for --no-wait
#22813
Conversation
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
f"with exitcode={commandResult.exit_code}{colorama.Style.RESET_ALL}") | ||
print(commandResult.logs) | ||
return | ||
if commandResult: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's drop condition here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed a misleading colon (:
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 invoke
az aks command result
Description
--no-wait
inaz aks command invoke
az aks command invoke
Testing 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.