[Core] Support track1 and track2 mgmt SDK side by side in CLI#12952
[Core] Support track1 and track2 mgmt SDK side by side in CLI#12952
Conversation
|
add to S168 |
| from msrestazure.azure_exceptions import CloudError | ||
|
|
||
| response = sdk_no_wait(True, client.generate) | ||
| response = client.generate(raw=True) |
There was a problem hiding this comment.
so. Is sdk_not_wait useless?
There was a problem hiding this comment.
No, sdk_not_wait is still useful for LRO as it will set "polling" to false if no_wait is true.
But here it should not use sdk_no_wait as it's not a LRO (I checked the SDK method.)
'raw' is another story which is different from LRO, so it should not be set in sdk_no_wait.
All other places I replace 'sdk_no_wait' with 'raw=True' actually are bug fix for those modules.
In reply to: 406657030 [](ancestors = 406657030)
| from msrestazure.azure_exceptions import CloudError | ||
|
|
||
| response = sdk_no_wait(True, client.generate) | ||
| response = client.generate(raw=True) |
There was a problem hiding this comment.
Maybe we can split the migration of advisor and backup to a different PR?
There was a problem hiding this comment.
| "https://docs.microsoft.com/cli/azure/query-azure-cli?view=azure-cli-latest") | ||
| return 1 | ||
| if isinstance(ex, (CLIError, CloudError, AzureException)): | ||
| if isinstance(ex, (CLIError, CloudError, AzureException, HttpResponseError, AzureError)): |
There was a problem hiding this comment.
Optional: HttpResponseError being a subclass of AzureError, you could simply catch AzureError
There was a problem hiding this comment.
| from msrestazure.azure_exceptions import CloudError | ||
|
|
||
| response = sdk_no_wait(True, client.generate) | ||
| response = client.generate(raw=True) |
There was a problem hiding this comment.
@Prasanna-Padmanabhan,
Here we pass raw=True in method instead of using sdk_no_wait (actually it's not correct to use sdk_no_wait before as client.generate is not a long running operation.), please help confirm this change.
There was a problem hiding this comment.
I don't have the necessary knowledge to sign off on this change. If all existing tests are passing, then you can go ahead.
There was a problem hiding this comment.
@Prasanna-Padmanabhan, thanks for your confirm. All existing tests are passing, so we'll commit this change.
| client_kwargs['headers'] = headers | ||
|
|
||
| if 'x-ms-client-request-id' in cli_ctx.data['headers']: | ||
| client_kwargs['request_id'] = cli_ctx.data['headers']['x-ms-client-request-id'] |
There was a problem hiding this comment.
Some questions here:
request_idis required for client?- Should we use
x-ms-request-id?
x-ms-request-id: This is a common response header that contains a unique identifier for the current operation, service generated.
x-ms-client-request-id: Optional. Contains a unique ID provided by the client to identify the specific request.
It looksx-ms-client--request-idis right. #WontFix
There was a problem hiding this comment.
Actually request_id will be set to "x-ms-client-request-id" in request header, you can check the code in azure core below:
def on_request(self, request):
# type: (PipelineRequest) -> None
"""Updates with the given request id before sending the request to the next policy.
:param request: The PipelineRequest object
:type request: ~azure.core.pipeline.PipelineRequest
"""
request_id = unset = object()
if 'request_id' in request.context.options:
request_id = request.context.options.pop('request_id')
if request_id is None:
return
elif self._request_id is None:
return
elif self._request_id is not _Unset:
request_id = self._request_id # type: ignore
elif self._auto_request_id:
request_id = str(uuid.uuid1()) # type: ignore
if request_id is not unset:
header = {"x-ms-client-request-id": request_id}
In reply to: 407376852 [](ancestors = 407376852)
da45cca to
c924cf4
Compare
Description of PR (Mandatory)
This PR does the following things to support track1 and track2 mgmt SDK side by side:
get_token()callback to support track2client_kwargsto replaceclient.configin track2HttpResponseErrorAzureErrorfrom track2rawargument for no wait and passrawexplicitly in method if necessary.parametersargument for generic update and use actual arguments in SDK instead.Testing Guide
History Notes:
(Fill in the following template if multiple notes are needed, otherwise PR title will be used for history note.)
[Component Name 1] (BREAKING CHANGE:) (az command:) make some customer-facing change.
[Component Name 2] (BREAKING CHANGE:) (az command:) make some customer-facing change.
This 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.