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

{Core} Add . in prefix for operation handler #12702

Merged
merged 1 commit into from
Mar 29, 2020
Merged

Conversation

Juliehzl
Copy link
Contributor

@Juliehzl Juliehzl commented Mar 23, 2020

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.


Description:
ResourceType is defined as enum with the following structure for each element:
DATA_STORAGE = ('azure.multiapi.storage', None)

If we have two Resource Types named DATA_STORAGE and DATA_STORAGESYNC with the following definition:

DATA_STORAGESYNC = ('azure.multiapi.storagesync.', None)
DATA_STORAGE = ('azure.multiapi.storage.', None)

and the following api versions in latest profile:

ResourceType.DATA_STORAGESYNC: '2015-12-01',
ResourceType.DATA_STORAGE: '2016-09-01',

For the command type with operations_tmpl = 'azure.mgmt.storagesync.operations#ManagementPoliciesOperations.{}', the condition will be fit for resource type DATA_STORAGE in original code and CLI will go into the path azure.multiapi.storage
with api version defined in DATA_STORAGE, not azure.multiapi.storagesync :

if operation.startswith(rt.import_prefix + '.'):
operation = operation.replace(rt.import_prefix,
get_versioned_sdk_path(self.cli_ctx.cloud.profile, rt,
operation_group=operation_group))

But the right api version should be in ResourceType.DATA_STORAGESYNC.
With the change, we can prevent such scenario and go into azure-multiapi-storagesync package as expected.

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

@yonzhan
Copy link
Collaborator

yonzhan commented Mar 23, 2020

add to S167

@haroldrandom
Copy link
Contributor

May I have some contexts?

@@ -534,7 +534,7 @@ def get_op_handler(self, operation, operation_group=None):
from azure.cli.core.profiles._shared import get_versioned_sdk_path

for rt in AZURE_API_PROFILES[self.cli_ctx.cloud.profile]:
if operation.startswith(rt.import_prefix):
if operation.startswith(rt.import_prefix + '.'):
Copy link
Member

Choose a reason for hiding this comment

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

While this does handles some scenarios (please provide some real use cases in the PR description), this still can't handle the keyvault track 1 and 2 SDKs' compatibility:

Track 1 SDK:

  • azure.keyvault

Track 2 SDK:

  • azure.keyvault.secrets
  • azure.keyvault.keys

azure.keyvault.secrets.SecretClient.xxx and azure.keyvault.keys.KeyClient.xxx will be matched as Track 1 SDK azure.keyvault..

Copy link
Member

Choose a reason for hiding this comment

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

the change itself looks resolving the issue mentioned in description, same question on is there multiple namespaces containing dot after first dot? such as azure.multipleapi.storage.blob, azure.multipleapi.storage.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.

@jiasli If azure.keyvault is totally replaced with submodules such as azure.keyvault.secrets and azure.keyvault.keys, there will be no problem.
But if the resource type for azure.keyvault still exists with new resource types with azure.keyvault.secrets and azure.keyvault.keys, it will have some problem.

@yungezz There are packages as you mentioned, e.g. azure.mgmt.resource in https://github.com/Azure/azure-cli/blob/dev/src/azure-cli-core/azure/cli/core/profiles/_shared.py#L44-L49 .

Copy link
Member

Choose a reason for hiding this comment

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

MGMT_RESOURCE_FEATURES = ('azure.mgmt.resource.features', 'FeatureClient')
MGMT_RESOURCE_LINKS = ('azure.mgmt.resource.links', 'ManagementLinkClient')
MGMT_RESOURCE_LOCKS = ('azure.mgmt.resource.locks', 'ManagementLockClient')
MGMT_RESOURCE_POLICY = ('azure.mgmt.resource.policy', 'PolicyClient')
MGMT_RESOURCE_RESOURCES = ('azure.mgmt.resource.resources', 'ResourceManagementClient')
MGMT_RESOURCE_SUBSCRIPTIONS = ('azure.mgmt.resource.subscriptions', 'SubscriptionClient')

This doesn't have problem because there is no azure.mgmt.resource that can cause the same conflict as azure.keyvault.

I am ok with this for now, but still we need to figure out a better solution.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. If you want to using submodules for keyvault, you cannot use azure.keyvault any more.

@bim-msft
Copy link
Contributor

What's the background of this modification?

@qwordy
Copy link
Member

qwordy commented Mar 24, 2020

This sentence "With the change, we can prevent such scenario and go into the" is incomplete

@Juliehzl
Copy link
Contributor Author

What's the background of this modification?

I have updated the description and you can take a look.

@Juliehzl
Copy link
Contributor Author

Juliehzl commented Mar 24, 2020

This sentence "With the change, we can prevent such scenario and go into the" is incomplete

Thanks! Updated. 😊

@bim-msft bim-msft self-requested a review March 24, 2020 06:28
Copy link
Contributor

@bim-msft bim-msft left a comment

Choose a reason for hiding this comment

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

LGTM

@yonzhan yonzhan modified the milestones: S167, S168 Mar 28, 2020
@Juliehzl Juliehzl merged commit daceea2 into Azure:dev Mar 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants