Skip to content

Conversation

@houk-ms
Copy link
Contributor

@houk-ms houk-ms commented Mar 10, 2021

Description

The security-domain download operation will introduce a breaking change from sync to async. The corresponding changs in swagger are as below

This PR works to support both sync and async operation before the changes are deployed in service side, so that we won't break the users in the latest CLI version. While the old versions of CLI will be broken anyway once the service changes are deployed, of which service team is clearly aware and would like us to do so.

The changes in the PR include

  • Add --no-wait paramter for command az keyvault security-domain download
  • Add --target-operation parameter for az keyvault security-domain wait, so that users could choose to wait either upload or download operation to finish. (Previously, the command is only for upload operation, so the paramter defaults to upload here in avoid of breaking change)
  • Support --id to specify URL of HSM for command az keyvault security-domain upload/download/wait, as discussed in az keyvault security-domain download does not support --id parameter for Managed HSM #17040

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 feature.


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

@houk-ms houk-ms added the KeyVault az keyvault label Mar 10, 2021
@houk-ms houk-ms requested a review from yungezz March 10, 2021 08:09
@houk-ms houk-ms self-assigned this Mar 10, 2021
@houk-ms houk-ms requested a review from fengzhou-msft as a code owner March 10, 2021 08:09
status = 'InProgress'

# keep polling if status is 'InProgress'
while status == 'InProgress':
Copy link
Member

Choose a reason for hiding this comment

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

set a timeout for Inprogress polling?

Copy link
Member

Choose a reason for hiding this comment

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

does that mean CLI user will wait till operation finished. For aync operation, shouldn't the polling be done in --wait ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's right. Implementation is updated now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

set a timeout for Inprogress polling?

I reused the existing codes which supports max_retry now, although i think we should not set it

@houk-ms houk-ms changed the title {KeyVault} Support security-domain download operation changes from sync to async [KeyVault] Add --no-wait for command az keyvault security-domain download and --target-operation for command az keyvault security-domain wait Mar 12, 2021
@houk-ms
Copy link
Contributor Author

houk-ms commented Mar 12, 2021

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@houk-ms houk-ms requested a review from yungezz March 12, 2021 06:54
c.argument('identifier', options_list=['--id'], validator=validate_vault_or_hsm, help='Id of the HSM.')
c.argument('resource_group_name', options_list=['--resource-group', '-g'],
help='Proceed only if HSM belongs to the specified resource group.')
c.argument('target_operation', arg_type=get_enum_type(CLISecurityDomainOperation),
Copy link
Member

Choose a reason for hiding this comment

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

final command will be ?

az keyvault security-domain wait --target_operation upload

Copy link
Contributor Author

Choose a reason for hiding this comment

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

--target_operation defaults to upload in avoid of breaking change. so either specifying --target-operation or not would work for upload.

for download, we have to specify --target-operation download

try:
with open(file_path, 'w') as f:
f.write(security_domain.value)
except: # pylint: disable=bare-except
Copy link
Member

Choose a reason for hiding this comment

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

any error to end user when save failed?

Copy link
Contributor Author

@houk-ms houk-ms Mar 12, 2021

Choose a reason for hiding this comment

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

These are the original implementations.
But you are right, we can show some error message here.

if not no_wait:
polling_ret = _wait_security_domain_operation(client, hsm_name, 'download')
# Due to service defect, status could be 'Success' or 'Succeeded' when it succeeded
if polling_ret and getattr(polling_ret, 'status', None) != 'Failed':
Copy link
Member

Choose a reason for hiding this comment

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

pls lower/upper case then compare on string

Copy link
Contributor Author

@houk-ms houk-ms Mar 12, 2021

Choose a reason for hiding this comment

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

I prefer we rely on service in avoid of risks in possible type convertion.


# v7.2-preview and v7.2 will change the upload operation from Sync to Async
# due to service defects, it returns 'Succeeded' before the change and 'Success' after the change
if ret and getattr(ret, 'status', None) in ['Succeeded', 'Success', 'Failed']:
Copy link
Member

Choose a reason for hiding this comment

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

align on case before string comparasion, to avoid service change

query_parameters = {}
query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')

# Construct headers
Copy link
Member

Choose a reason for hiding this comment

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

[thumb up]!

@houk-ms
Copy link
Contributor Author

houk-ms commented Mar 18, 2021

Service team confirmed the changes work as expected.

@houk-ms houk-ms merged commit 424e804 into Azure:dev Mar 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

KeyVault az keyvault

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants