Skip to content
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

{KeyVault} Track 2 mgmt-plane adoption #14150

Merged
merged 109 commits into from
Aug 21, 2020
Merged

Conversation

bim-msft
Copy link
Contributor

@bim-msft bim-msft commented Jun 30, 2020

Use azure-mgmt-keyvault==7.0.0b2.
This is just an internal upgrade, the UX didn't change.


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

@yonzhan
Copy link
Collaborator

yonzhan commented Aug 19, 2020

KeyVault

Copy link
Contributor

@arrownj arrownj left a comment

Choose a reason for hiding this comment

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

What's this src/azure-cli/azure/cli/command_modules/keyvault/tests/latest/cert_secret file for ?

@@ -636,6 +636,9 @@ def get_provisioning_state(instance):
properties = getattr(instance, 'properties', None)
if properties:
provisioning_state = getattr(properties, 'provisioning_state', None)
if not provisioning_state:
additional_properties = getattr(properties, 'additional_properties', {})
provisioning_state = additional_properties.get('provisioningState')
Copy link
Contributor

Choose a reason for hiding this comment

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

For this case, is privisioningState always existing ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@arrownj This is a bug in core. The provisioningState label for keyvault is under properties.provisioning_state.additional_properties, the original code was not able to read it.

Copy link
Member

Choose a reason for hiding this comment

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

better to add some comments here to explain it

raise CLIError("The specified resource group does not match that of the deleted vault %s. The vault "
"must be recovered to the original resource group %s."
% (vault_name, id_comps['resource_group']))
if 'purge' not in cmd.name:
Copy link
Contributor

Choose a reason for hiding this comment

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

What's purge for ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@arrownj az keyvault purge doesn't require parameter resource_group. In track 1, if we pass an additional resource_group argument into purge function, it would be ignored. But in track 2, any unexpected arguments would cause a failure.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The code below line 245 is for automatically setting resource_group parameter.

g.custom_command('list', 'list_keyvault')
g.show_command('show', 'get')

g.command('purge', 'begin_purge_deleted', supports_no_wait=True)
Copy link
Contributor

Choose a reason for hiding this comment

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

Are these new commands ? It seems that we didn't add test for them.

Copy link
Contributor Author

@bim-msft bim-msft Aug 20, 2020

Choose a reason for hiding this comment

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

@arrownj No, it's an old command. Actually purge command has been already covered:

Copy link
Contributor

@arrownj arrownj Aug 20, 2020

Choose a reason for hiding this comment

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

seems line 71 ~ 73 is duplicated with line 81 ~ 83

Copy link
Contributor Author

Choose a reason for hiding this comment

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

seems line 71 ~ 73 is duplicated with line 81 ~ 83

@arrownj Good catch! Removed.

@bim-msft
Copy link
Contributor Author

bim-msft commented Aug 20, 2020

What's this src/azure-cli/azure/cli/command_modules/keyvault/tests/latest/cert_secret file for ?

@arrownj dev branch also has this file. Binary files wouldn't show anything in git diff.

@@ -35,6 +35,11 @@
from msrest.exceptions import HttpOperationError
"""

track2_header = copyright_header + b"""import msrest.serialization
Copy link
Member

Choose a reason for hiding this comment

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

this is quite hack. is there better way to do it, like feedback to sdk team, maybe add it in track2 generation as a option?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@yungezz Actually the SDK is great, the problem is within this patch_models.py script. This script is totally a hack script.

@@ -220,7 +229,15 @@ def find_autorest_generated_folder(module_prefix="azure.mgmt"):
if __name__ == "__main__":
logging.basicConfig(level=logging.INFO)

track2_packages = [
'azure.mgmt.keyvault'
Copy link
Member

Choose a reason for hiding this comment

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

will future track2 mgmt sdks need to add this line also?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@yungezz Yes, I think. Anyway, this is a hack script and maybe we should totally understand it and try to deprecate it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This script was involved at this point: #7061 The motivation is to resolve SDK model references. I think track 2 SDKs won't have the reference related issue.

@@ -636,6 +636,9 @@ def get_provisioning_state(instance):
properties = getattr(instance, 'properties', None)
if properties:
provisioning_state = getattr(properties, 'provisioning_state', None)
if not provisioning_state:
additional_properties = getattr(properties, 'additional_properties', {})
provisioning_state = additional_properties.get('provisioningState')
Copy link
Member

Choose a reason for hiding this comment

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

better to add some comments here to explain it

@@ -388,3 +388,12 @@
az keyvault update --enabled-for-disk-encryption true --name MyKeyVault --resource-group MyResourceGroup
crafted: true
"""

helps['keyvault wait'] = """
Copy link
Member

Choose a reason for hiding this comment

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

is this a new command? or just fix of help file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

is this a new command? or just fix of help file?

@yungezz This is for LRO. keyvault create and keyvault purge became LRO in track 2.

no_wait = kwargs.pop('no_wait')

if cmd.cli_ctx.cloud.profile == 'latest':
function_name = 'begin_' + function_name
Copy link
Member

Choose a reason for hiding this comment

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

this is also specific to track2 right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@yungezz Yes, track 2 only.

Copy link
Contributor

Choose a reason for hiding this comment

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

it only applies to latest profile and for existing 2019-03-01-hybrid profile with api version 2016-10-01, you will still use track 1 SDK, right?
But there is a plan to create a new profile named 2020-09-01-hybrid with api version 2019-09-01, if new profile is used you will still go to track1 SDK, is it expected?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Juliehzl No, all profiles after this commit will use track 2. For the new plan we also use track 2. Track 1 would be abandoned at this point. (Management-plane only)

Copy link
Contributor

@arrownj arrownj left a comment

Choose a reason for hiding this comment

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

LGTM

@bim-msft
Copy link
Contributor Author

Hi @fengzhou-msft You are the code owner of scripts/sdk_process/patch_models.py, could please take a look?

Comment on lines +92 to +93
g.custom_command('add', 'add_network_rule', supports_no_wait=True)
g.custom_command('remove', 'remove_network_rule', supports_no_wait=True)
Copy link
Contributor

Choose a reason for hiding this comment

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

in these scenarios, is there a wait command to wait util condition satisfied?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Juliehzl Good catch. Added.

Copy link
Contributor

@Juliehzl Juliehzl left a comment

Choose a reason for hiding this comment

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

Approve for azure_stack_wrapper

@bim-msft bim-msft merged commit 3ffbdb8 into Azure:dev Aug 21, 2020
@bim-msft bim-msft deleted the bim_kv_track2_mgmt branch August 21, 2020 05:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants