-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[Compute] az vmss create/update: support automatic repairs #12374
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
Changes from 4 commits
f82897a
9795d9e
f1ff97d
81b79a4
1efdc92
4b3219f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1409,6 +1409,7 @@ def process_vmss_create_namespace(cmd, namespace): | |
| _validate_vm_vmss_msi(cmd, namespace) | ||
| _validate_proximity_placement_group(cmd, namespace) | ||
| _validate_vmss_terminate_notification(cmd, namespace) | ||
| _validate_vmss_create_automatic_repairs(cmd, namespace) | ||
|
|
||
| if namespace.secrets: | ||
| _validate_secrets(namespace.secrets, namespace.os_type) | ||
|
|
@@ -1429,6 +1430,7 @@ def validate_vmss_update_namespace(cmd, namespace): # pylint: disable=unused-ar | |
| raise CLIError("usage error: protection policies can only be applied to VM instances within a VMSS." | ||
| " Please use --instance-id to specify a VM instance") | ||
| _validate_vmss_update_terminate_notification_related(cmd, namespace) | ||
| _validate_vmss_update_automatic_repairs(cmd, namespace) | ||
| # endregion | ||
|
|
||
|
|
||
|
|
@@ -1633,3 +1635,27 @@ def _validate_vmss_terminate_notification(cmd, namespace): # pylint: disable=un | |
| """ | ||
| if namespace.terminate_notification_time is not None: | ||
| namespace.terminate_notification_time = 'PT' + namespace.terminate_notification_time + 'M' | ||
|
|
||
|
|
||
| def _validate_vmss_create_automatic_repairs(cmd, namespace): # pylint: disable=unused-argument | ||
| if namespace.automatic_repairs_grace_period is not None: | ||
| if namespace.load_balancer is None or namespace.health_probe is None: | ||
| raise CLIError("usage error: --load-balancer and --health-probe are required " | ||
| "when creating vmss with automatic repairs") | ||
| _validate_vmss_automatic_repairs(cmd, namespace) | ||
|
|
||
|
|
||
| def _validate_vmss_update_automatic_repairs(cmd, namespace): # pylint: disable=unused-argument | ||
| if namespace.enable_automatic_repairs is False and namespace.automatic_repairs_grace_period is not None: | ||
| raise CLIError("usage error: please enable --enable-automatic-repairs") | ||
| if namespace.enable_automatic_repairs is True and namespace.automatic_repairs_grace_period is None: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it necessary? Based on your description, I think we can drop this check here.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you mean we leave this validation to service side ?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. default value 30? maybe you can omit this validation
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. per discussed offline, let's just keep this validation. |
||
| raise CLIError("usage error: please set --automatic-repairs-grace-period") | ||
| _validate_vmss_automatic_repairs(cmd, namespace) | ||
|
|
||
|
|
||
| def _validate_vmss_automatic_repairs(cmd, namespace): # pylint: disable=unused-argument | ||
| """ | ||
| Transform minutes to ISO 8601 formmat | ||
| """ | ||
| if namespace.automatic_repairs_grace_period is not None: | ||
| namespace.automatic_repairs_grace_period = 'PT' + namespace.automatic_repairs_grace_period + 'M' | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall we use
action='store_true'instead ofget_three_state_flag?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe
get_three_state_flagis also fine.automaticRepairsPolicyis a property of the resource, andenable_automatic_repairscould be considered as theenabledproperty ofautomaticRepairsPolicy.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest to put
enable_automatic_repairsandautomatic_repairs_grace_periodin an argument group so customers know that these two arguments need to be used together.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, they are in the same argument group.
enable_automatic_repairsandautomatic_repairs_grace_periodare inaz vmss update. While onlyautomatic_repairs_grace_periodinaz vmss create. You can reference above discussion with Catherine, I explain why we design like this. And want to hear your options. ThanksThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean you can add something like
arg_group='Automatic Repair Policy', otherwise the two options are apart from each other in alpabetic order in help message. Usually we name the second level property with a prefix of first level property, they will be showed together in help message, for instance, the names could beautomatic_repairs_policy_enable,automatic_reapirs_policy_grace_period, but the first name looks weird withenableas suffix, so I think arg_group can work well in this case.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
arg_group added