-
Notifications
You must be signed in to change notification settings - Fork 3.4k
[Compute] Add VMSS Automatic Zone Placement CLI Support #32771
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
base: dev
Are you sure you want to change the base?
Changes from all commits
527b733
e3e9d75
ac028a4
bc64d92
c018c31
1d05783
dbc4173
2e61a5a
52603c0
08ea7e9
b267e81
802812f
7a58996
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 |
|---|---|---|
|
|
@@ -1824,6 +1824,7 @@ def process_vmss_create_namespace(cmd, namespace): | |
| raise ArgumentUsageError('usage error: please specify the --image when you want to specify the VM SKU') | ||
|
|
||
| _validate_trusted_launch(namespace) | ||
| _validate_vmss_create_auto_zone_placement(namespace) | ||
| if namespace.image: | ||
|
|
||
| if namespace.vm_sku is None: | ||
|
|
@@ -1920,6 +1921,7 @@ def process_vmss_create_namespace(cmd, namespace): | |
| _validate_vmss_terminate_notification(cmd, namespace) | ||
| _validate_vmss_create_automatic_repairs(cmd, namespace) | ||
| _validate_vmss_create_host_group(cmd, namespace) | ||
| _validate_vmss_create_auto_zone_placement(namespace) | ||
|
|
||
| if namespace.secrets: | ||
| _validate_secrets(namespace.secrets, namespace.os_type) | ||
|
|
@@ -2636,6 +2638,91 @@ def _validate_vmss_create_host_group(cmd, namespace): | |
| ) | ||
|
|
||
|
|
||
| def _validate_vmss_create_auto_zone_placement(namespace): | ||
|
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. why do we need to add a validation function?
Member
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. Because this function requires some verification before creating/updating resources.
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. Why do we need the verification? I don’t see any request to add verification in the feature request.
Member
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. They have provided documentation specifying which parameters are required, or which parameters cannot be set if they are set. The function I added, _validate_vmss_create_auto_zone_placement, is for performing these validations. |
||
| zpp = getattr(namespace, 'zone_placement_policy', None) | ||
| zones = getattr(namespace, 'zones', None) | ||
| zone_balance = getattr(namespace, 'zone_balance', None) | ||
| max_zone_count = getattr(namespace, 'max_zone_count', None) | ||
| disable_overprovision = getattr(namespace, 'disable_overprovision', None) | ||
| ppg = getattr(namespace, 'ppg', None) | ||
| crg = getattr(namespace, 'capacity_reservation_group', None) | ||
| orchestration_mode = getattr(namespace, 'orchestration_mode', None) | ||
| instance_percent_policy = getattr(namespace, 'instance_percent_policy', None) | ||
| max_instance_percent = getattr(namespace, 'max_instance_percent', None) | ||
|
|
||
| # "zones", zonePlacementPolicy cannot be enabled if "zones" list exists on the scale set | ||
| if zpp and zones: | ||
| raise CLIError( | ||
| "usage error: --zone-placement-policy cannot be used with --zones. " | ||
| "Specify either fixed zones (--zones) or automatic zone placement (--zone-placement-policy)." | ||
| ) | ||
|
|
||
| # zonePlacementPolicy allowed values | ||
| if zpp and str(zpp).lower() != 'auto': | ||
| raise CLIError( | ||
| "usage error: unsupported value for --zone-placement-policy. Only 'Auto' is supported." | ||
| ) | ||
|
|
||
| # max-zone-count must be positive | ||
| if max_zone_count is not None and max_zone_count <= 0: | ||
| raise CLIError( | ||
| "usage error: --max-zone-count must be a positive integer." | ||
| ) | ||
|
|
||
| # zoneBalance=true requires maxZoneCount | ||
| if zone_balance is True and max_zone_count is None: | ||
| raise CLIError( | ||
| "usage error: --zone-balance requires --max-zone-count to be specified." | ||
| ) | ||
|
|
||
| # Zones=Auto does not support overprovisioning | ||
| if zpp and orchestration_mode and orchestration_mode.lower() == 'uniform': | ||
| if not disable_overprovision: | ||
| raise CLIError( | ||
| "usage error: zone placement policy does not support overprovisioning. " | ||
| "Set --disable-overprovision when using --zone-placement-policy Auto." | ||
| ) | ||
|
|
||
| # zones=Auto does not support Proximity Placement Group | ||
| if zpp and ppg: | ||
| raise CLIError( | ||
| "usage error: zone placement policy does not support proximity placement groups." | ||
| ) | ||
|
|
||
| # zones=Auto does not support Capacity Reservation Group | ||
| if zpp and crg: | ||
| raise CLIError( | ||
| "usage error: zone placement policy does not support capacity reservation groups." | ||
| ) | ||
|
|
||
| if instance_percent_policy is not None: | ||
| # enable=true requires value | ||
| if instance_percent_policy is True and max_instance_percent is None: | ||
| raise CLIError( | ||
| "usage error: --instance-percent-policy true requires " | ||
| "(--max-instance-percent / --value-max-instance-percent-per-zone)." | ||
| ) | ||
|
|
||
| # enable=false should not be combined with value | ||
| if instance_percent_policy is False and max_instance_percent is not None: | ||
| raise CLIError( | ||
| "usage error: (--max-instance-percent / --value-max-instance-percent-per-zone) cannot be used when " | ||
| "--instance-percent-policy is false." | ||
| ) | ||
|
|
||
| # value range | ||
| if max_instance_percent is not None: | ||
| if instance_percent_policy is None: | ||
| raise CLIError( | ||
| "usage error: (--max-instance-percent / --value-max-instance-percent-per-zone) cannot be used when " | ||
| "--instance-percent-policy is not set." | ||
| ) | ||
|
|
||
| if max_instance_percent < 1 or max_instance_percent > 100: | ||
| raise CLIError("usage error: (--max-instance-percent / --value-max-instance-percent-per-zone) must be an " | ||
| "integer between 1 and 100.") | ||
|
|
||
|
|
||
| def _validate_count(namespace): | ||
| if namespace.count < 2 or namespace.count > 250: | ||
| raise ValidationError( | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.