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

[SQL] 'az sql mi update: Add --tier and --family` parameters to change hw generation #11852

Merged
merged 18 commits into from
Feb 9, 2020

Conversation

v-nestan
Copy link
Contributor

@v-nestan v-nestan commented Jan 14, 2020

This change adds support for changing existing managed instance hardware generation.

TFS item link

History Notes:
[SQL] Update SQL Managed Instance cmdlet az sql mi update with two new parameters: tier and family.


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

  • The PR has modified HISTORY.rst describing any customer-facing, functional changes. Note that this does not include changes only to help content. (see Modifying change log).

  • I adhere to the Command Guidelines.

@jsntcy
Copy link
Member

jsntcy commented Jan 15, 2020

@Juliehzl, please help review it, thanks.

@@ -2134,6 +2134,12 @@ def _find_managed_instance_sku_from_capabilities(cli_ctx, location, sku):
# Find family level capability, based on requested sku properties
family_capability = _find_family_capability(sku, edition_capability.supported_families)

# Check whether hardware family is being changed to a deprecated hardware family
if not is_instance_create:
if current_sku_family == 'Gen5' and 'Gen4' in family_capability.sku:
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this being done client-side instead of server-side (MI provision operation authorizer)? These sorts of policy decisions should not be coded into CLI

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 idea was to fast fail if a customer tries to change hardware family to a deprecated hardware family. Synced with PM, and we agreed to remove this check as you suggested. Thanks

'family',
'name',
'tier',
])
Copy link
Contributor

@jaredmoo jaredmoo Jan 15, 2020

Choose a reason for hiding this comment

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

Can you show the output of az sql mi create -h and az sql mi update -h, and make sure that sku-related params have same UX as az sql db create -h?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've aligned them

az sql mi create -h
image

az sql mi update -h
image

az sql db create -h
image

@@ -74,6 +74,10 @@ Release History
* Add new parameters `--enable-delete-retention` and `--delete-retention-days` to support managing delete retention policy for storage account blob-service-properties.


**SQL**
Copy link
Contributor

@Juliehzl Juliehzl Jan 19, 2020

Choose a reason for hiding this comment

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

Please rearrange the release note in the right position and use active voice for your commands

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

@@ -1156,7 +1156,8 @@ def _configure_security_policy_storage_params(arg_ctx):

c.argument('tier',
arg_type=tier_param_type,
help='The edition component of the sku. Allowed values: GeneralPurpose, BusinessCritical.')
help='The edition component of the sku. Allowed values include:'
Copy link
Contributor

Choose a reason for hiding this comment

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

please use get_enum_types() for allowed values.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. I've done the same thing for family too

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.

@v-nestan please fix CI errors and if @jaredmoo agree, I am fine to merge it.

@@ -559,6 +559,8 @@
examples:
- name: Updates a mi with specified parameters and with identity
text: az sql mi update -g mygroup -n myinstance -i -p mypassword --license-type mylicensetype --capacity vcorecapacity --storage storagesize
- name: Updates mi edition and hardware family
Copy link
Contributor

Choose a reason for hiding this comment

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

Updates -> Update

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

@@ -559,6 +559,8 @@
examples:
- name: Updates a mi with specified parameters and with identity
text: az sql mi update -g mygroup -n myinstance -i -p mypassword --license-type mylicensetype --capacity vcorecapacity --storage storagesize
- name: Updates mi edition and hardware family
text: az sql mi update -g mygroup -n myinstance -tier GeneralPurpose -family Gen5
Copy link
Contributor

Choose a reason for hiding this comment

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

It should be --tier and --family.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Corrected. Thanks

@Juliehzl Juliehzl changed the title Nemanjas/mi change hw generation [SQL] 'az sql mi update: Add --tier and --family` parameters to change hw generation Jan 19, 2020
@Juliehzl
Copy link
Contributor

Please follow above template for your PR title in future.

Nemanja added 3 commits January 27, 2020 12:35
Fixing _help.py
Using get_enum_type() for allowed values
@v-nestan v-nestan force-pushed the nemanjas/mi_change_hw_generation branch from c055879 to c2f1037 Compare January 27, 2020 14:59
@@ -56,7 +56,9 @@
ComputeModelType,
DatabaseCapabilitiesAdditionalDetails,
ElasticPoolCapabilitiesAdditionalDetails,
FailoverPolicyType
FailoverPolicyType,
ManagedInstanceTiers,
Copy link
Contributor

Choose a reason for hiding this comment

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

style nitpick: It should be singular, i.g. ManagedInstanceTier & ManagedInstanceFamily

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've removed those because they are not needed any more since I've removed get_enum_type()

help='The compute generation component of the sku. '
'Allowed values include: Gen4, Gen5.')
arg_type=mi_family_param_type,
help='The compute generation component of the sku.')
Copy link
Contributor

Choose a reason for hiding this comment

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

Does get_enum_type() throw error if you don't specify one of the allowed values? This will prevent forward compatibility (i.e. when we release Gen1234, customers will not be able to manually type it in until they download newer CLI version) - this has previously been a frustration for SQL DB customers. We should allow customer to type in anything, then if we validate it must be against a dynamic list (e.g. capabilities API) and NOT a hardcoded list.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've checked now and it does throws an error. For example

az sql mi update --subscription "DS-CloudLifter_jovanc_R&D_60843" --resource-group 201tmpl --name nestan-testing109 --family Gen52
az sql mi update: 'Gen52' is not a valid value for '--family'. See 'az sql mi update --help'.

The most similar choice to 'Gen52' is:
Gen5

I'll remove the get_enum_type :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for pointing this up

return sku

if not _any_sku_values_specified(sku):
if is_instance_create and not _any_sku_values_specified(sku):
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is is_instance_create logic needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right it is redundant.
The idea was to protect from getting a default sku name when sku components are not entered during update SLO

However, since SKU for existing instance is populated before this method is called, default sku will not be taken for update SLO.

I'll remove it

instance,
administrator_login_password=None,
license_type=None,
vcores=None,
storage_size_in_gb=None,
assign_identity=False,
proxy_override=None,
public_data_endpoint_enabled=None):
public_data_endpoint_enabled=None,
sku=None):
Copy link
Contributor

Choose a reason for hiding this comment

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

In the interest of alignment & reducing overall complexity, would it make sense to use same syntax as db_update function (i.e. split it up into components):

        tier=None,
        family=None,
        capacity=None,

?

Copy link
Contributor

Choose a reason for hiding this comment

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

Just remembered that MI has vcores property, not capacity. Blergh

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll replace sku with tier and family. I'll omit the third component of sku because it is not needed

@@ -2211,6 +2221,16 @@ def managed_instance_update(
instance.proxy_override = (
proxy_override or instance.proxy_override)

Copy link
Contributor

Choose a reason for hiding this comment

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

Should you set sku.name = None here?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it makes sense to null out the sku name here, because there is no requested sku name, and you don't yet know what the sku name will be (it will be found based on tier & family).

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, it makes sense to set it to None here

Removing redundant parameter `is_instance_create`
Replacing `sku` with `tier` and `family` in `managed_instance_update` for consistency with db_update
@yonzhan yonzhan added this to the S164 milestone Jan 28, 2020
@yonzhan yonzhan modified the milestones: S164, S165 Jan 28, 2020
@yonzhan yonzhan requested a review from qianwens January 28, 2020 08:29
@yonzhan
Copy link
Collaborator

yonzhan commented Jan 28, 2020

add to S165.

@@ -51,6 +51,10 @@ Release History
* `az storage remove`: Change `--inlcude` and `--exclude` parameters to `--include-path`, `--include-pattern`, `--exclude-path` and`--exclude-pattern` parameters
* `az storage sync`: Add `--include-pattern`, `--exclude-path` and`--exclude-pattern` parameters

**SQL**

* Update az sql mi update with two new properties tier and family.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: please format this string little better. It sound weird: "Update az sql mi update". Also "properties: tier and family"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. Thanks

@@ -2098,21 +2098,18 @@ def encryption_protector_update(
# sql managed instance #
###############################################


Copy link
Contributor

Choose a reason for hiding this comment

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

removing this line is causing validation to fail, please return it

@@ -2211,6 +2211,16 @@ def managed_instance_update(
instance.proxy_override = (
proxy_override or instance.proxy_override)

instance.sku.name = None
Copy link
Contributor

Choose a reason for hiding this comment

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

tiny nit: consider commenting the reason why you do this, since it would not be obvious when first reading

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.

LGTM in general. Please make CI pass.

@Juliehzl Juliehzl merged commit fd39d4b into Azure:dev Feb 9, 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.

6 participants