Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -251,12 +251,6 @@ def _flexible_server_params(command_group):
help="The availability zone information of the standby server when high availability is enabled."
)

high_availability_arg_type = CLIArgumentType(
arg_type=get_enum_type(['ZoneRedundant', 'SameZone', 'Disabled']),
options_list=['--high-availability'],
help='Enable (ZoneRedundant or SameZone) or disable high availability feature.'
)

zonal_resiliency_arg_type = CLIArgumentType(
arg_type=get_enum_type(['Enabled', 'Disabled']),
options_list=['--zonal-resiliency'],
Expand Down Expand Up @@ -412,7 +406,6 @@ def _flexible_server_params(command_group):
c.argument('location', arg_type=get_location_type(self.cli_ctx))
c.argument('administrator_login', default=generate_username(), arg_type=administrator_login_arg_type)
c.argument('administrator_login_password', arg_type=administrator_login_password_arg_type)
c.argument('high_availability', arg_type=high_availability_arg_type, default="Disabled")
c.argument('public_access', arg_type=public_access_create_arg_type)
c.argument('vnet', arg_type=vnet_arg_type)
c.argument('subnet', arg_type=subnet_arg_type)
Expand Down Expand Up @@ -484,7 +477,6 @@ def _flexible_server_params(command_group):
c.argument('sku_name', arg_type=sku_name_arg_type)
c.argument('storage_gb', arg_type=storage_gb_arg_type)
c.argument('standby_availability_zone', arg_type=standby_availability_zone_arg_type)
c.argument('high_availability', arg_type=high_availability_arg_type)
c.argument('byok_key', arg_type=key_arg_type)
c.argument('byok_identity', arg_type=identity_arg_type)
c.argument('backup_byok_identity', arg_type=backup_identity_arg_type)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def flexible_server_create(cmd, client,
password_auth=None, administrator_login=None, administrator_login_password=None,
tags=None, subnet=None, vnet=None,
private_dns_zone_arguments=None, public_access=None,
high_availability=None, zonal_resiliency=None, allow_same_zone=False,
zonal_resiliency=None, allow_same_zone=False,
zone=None, standby_availability_zone=None,
geo_redundant_backup=None, byok_identity=None, byok_key=None, backup_byok_identity=None, backup_byok_key=None,
auto_grow=None, performance_tier=None,
Expand All @@ -93,7 +93,7 @@ def flexible_server_create(cmd, client,
logging_name='PostgreSQL', command_group='postgres', server_client=client, location=location)

server_name = server_name.lower()
high_availability_mode = high_availability
high_availability_mode = "Disabled"

if (sku_name is None) or (version is None) or \
(zonal_resiliency is not None and zonal_resiliency.lower() != 'disabled'):
Expand Down Expand Up @@ -126,7 +126,6 @@ def flexible_server_create(cmd, client,
auto_grow=auto_grow,
storage_type=storage_type,
iops=iops, throughput=throughput,
high_availability=high_availability,
zonal_resiliency=zonal_resiliency,
allow_same_zone=allow_same_zone,
standby_availability_zone=standby_availability_zone,
Expand Down Expand Up @@ -412,7 +411,6 @@ def flexible_server_update_custom_func(cmd, client, instance,
storage_gb=None,
backup_retention=None,
administrator_login_password=None,
high_availability=None,
zonal_resiliency=None,
allow_same_zone=False,
standby_availability_zone=None,
Expand Down Expand Up @@ -444,7 +442,6 @@ def flexible_server_update_custom_func(cmd, client, instance,
auto_grow=auto_grow,
iops=iops,
throughput=throughput,
high_availability=high_availability,
zonal_resiliency=zonal_resiliency,
allow_same_zone=allow_same_zone,
zone=instance.availability_zone,
Expand Down Expand Up @@ -559,6 +556,7 @@ def flexible_server_update_custom_func(cmd, client, instance,

# High availability can't be updated with existing properties
high_availability_param = postgresql_flexibleservers.models.HighAvailability()
high_availability = None
if zonal_resiliency is not None:
if zonal_resiliency.lower() == 'disabled':
high_availability = 'Disabled'
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -186,15 +186,14 @@ def _test_mgmt_create_validator(self, resource_group):
invalid_tier = self.create_random_name('tier', RANDOM_VARIABLE_MAX_LENGTH)
valid_tier = 'GeneralPurpose'
invalid_backup_retention = 40
ha_value = 'ZoneRedundant'
zonal_resiliency_value = 'Enabled'
valid_vnet_name = self.create_random_name('vnet', RANDOM_VARIABLE_MAX_LENGTH)
invalid_vnet_name = self.create_random_name('vnet(/?\\)', RANDOM_VARIABLE_MAX_LENGTH)
valid_subnet_name = self.create_random_name('subnet', RANDOM_VARIABLE_MAX_LENGTH)
invalid_subnet_name = self.create_random_name('subnet(/?\\)', RANDOM_VARIABLE_MAX_LENGTH)
valid_vnet_identifier = '/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resource-group/providers/Microsoft.Network/virtualNetworks/{}'.format(valid_vnet_name)
invalid_vnet_identifier = '/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resource-group/providers/Microsoft.Network/virtualNetworks/{}'.format(invalid_vnet_name)
valid_subnet_identifier = '/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resource-group/providers/Microsoft.Network/virtualNetworks/{}/subnets/{}'.format(valid_vnet_name, valid_subnet_name)
invalid_subnet_identifier = '/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resource-group/providers/Microsoft.Network/virtualNetworks/{}/subnets/{}'.format(invalid_vnet_name, invalid_subnet_name)
valid_private_dns_zone = '{}.private.postgres.database.azure.com'.format(server_name)
invalid_private_dns_zones = ['{}.postgres.database.azure.com'.format(server_name), 'invalidprivate.dns.zone', '/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resource-group/providers/Microsoft.Network/privateDnsZones/{}.invalid(/?\\)segment.postgres.database.azure.com'.format(server_name)]

Expand Down Expand Up @@ -223,24 +222,24 @@ def _test_mgmt_create_validator(self, resource_group):
resource_group, server_name, location, invalid_backup_retention),
expect_failure=True)

# Create server with zone redundant high availability in a location that does not support it, because it's a single zone location.
self.cmd('postgres flexible-server create -g {} -n {} -l {} --high-availability {} '.format(
resource_group, server_name, location, ha_value),
# Create server with zone redundant high availability in a location that does not support it, because it's a single zone location
self.cmd('postgres flexible-server create -g {} -n {} -l {} --zonal-resiliency {} '.format(
resource_group, server_name, location, zonal_resiliency_value),
expect_failure=True)

# Create server with zone redundant high availability with a tier that does not support it.
self.cmd('postgres flexible-server create -g {} -n {} -l {} --tier Burstable --sku-name Standard_B1ms --high-availability {}'.format(
resource_group, server_name, location, ha_value),
# Create server with zone redundant high availability with a tier that does not support it
self.cmd('postgres flexible-server create -g {} -n {} -l {} --tier Burstable --sku-name Standard_B1ms --zonal-resiliency {}'.format(
resource_group, server_name, location, zonal_resiliency_value),
expect_failure=True)

# Create server with zone redundant high availability in a location that does not support it, because it's a single zone location.
self.cmd('postgres flexible-server create -g {} -n {} -l {} --tier GeneralPurpose --sku-name Standard_D4ds_v4 --high-availability {}'.format(
resource_group, server_name, location, ha_value),
# Create server with zone redundant high availability in a location that does not support it, because it's a single zone location
self.cmd('postgres flexible-server create -g {} -n {} -l {} --tier GeneralPurpose --sku-name Standard_D4ds_v4 --zonal-resiliency {}'.format(
resource_group, server_name, location, zonal_resiliency_value),
expect_failure=True)

# Create server with zone redundant high availability and forcing same zone for primary and standby.
self.cmd('postgres flexible-server create -g {} -n {} -l {} --tier GeneralPurpose --sku-name Standard_D2ads_v5 --high-availability {} --zone 1 --standby-zone 1'.format(
resource_group, server_name, location, ha_value),
# Create server with zone redundant high availability and forcing same zone for primary and standby
self.cmd('postgres flexible-server create -g {} -n {} -l {} --tier GeneralPurpose --sku-name Standard_D2ads_v5 --zonal-resiliency {} --zone 1 --standby-zone 1'.format(
resource_group, server_name, location, zonal_resiliency_value),
expect_failure=True)

# Create server with private network arguments but without a private DNS zone.
Expand Down Expand Up @@ -370,11 +369,11 @@ def _test_mgmt_update_validator(self, resource_group):
expect_failure=True)

# Update server with high availability on a tier that does not support it
ha_value = 'ZoneRedundant'
self.cmd('postgres flexible-server update -g {} -n {} --high-availability {}'.format(
resource_group, server_name, ha_value),
zonal_resiliency_value = 'Enabled'
self.cmd('postgres flexible-server update -g {} -n {} --zonal-resiliency {}'.format(
resource_group, server_name, zonal_resiliency_value),
expect_failure=True)

# Delete server
self.cmd('postgres flexible-server delete -g {} -n {} --yes'.format(
resource_group, server_name), checks=NoneCheck())
resource_group, server_name), checks=NoneCheck())
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def validate_private_endpoint_connection_id(cmd, namespace):

# pylint: disable=too-many-locals
def pg_arguments_validator(db_context, location, tier, sku_name, storage_gb, server_name=None, database_name=None,
zone=None, standby_availability_zone=None, high_availability=None,
zone=None, standby_availability_zone=None,
zonal_resiliency=None, allow_same_zone=False, subnet=None,
public_access=None, version=None, instance=None, geo_redundant_backup=None,
byok_identity=None, byok_key=None, backup_byok_identity=None, backup_byok_key=None,
Expand Down Expand Up @@ -196,8 +196,8 @@ def pg_arguments_validator(db_context, location, tier, sku_name, storage_gb, ser
_pg_georedundant_backup_validator(geo_redundant_backup, geo_backup_supported)
_pg_storage_validator(storage_gb, sku_info, tier, storage_type, iops, throughput, instance)
_pg_sku_name_validator(sku_name, sku_info, tier, instance)
_pg_high_availability_validator(high_availability, zonal_resiliency, allow_same_zone,
standby_availability_zone, zone, tier, single_az, instance)
_pg_zonal_resiliency_validator(zonal_resiliency, allow_same_zone,
standby_availability_zone, zone, tier, single_az, instance)
pg_version_validator(version, list_location_capability_info['server_versions'])
pg_byok_validator(byok_identity, byok_key, backup_byok_identity, backup_byok_key, geo_redundant_backup, instance)
is_microsoft_entra_auth = bool(microsoft_entra_auth is not None and microsoft_entra_auth.lower() == 'enabled')
Expand Down Expand Up @@ -344,27 +344,14 @@ def pg_version_validator(version, versions):
'maintain security, performance, and supportability.')


def _pg_high_availability_validator(high_availability, zonal_resiliency, allow_same_zone,
standby_availability_zone, zone, tier, single_az, instance):
high_availability_enabled = (high_availability is not None and high_availability.lower() != 'disabled')
def _pg_zonal_resiliency_validator(zonal_resiliency, allow_same_zone,
standby_availability_zone, zone, tier, single_az, instance):
zonal_resiliency_enabled = (zonal_resiliency is not None and zonal_resiliency.lower() != 'disabled')
high_availability_zone_redundant = (high_availability_enabled and high_availability.lower() == 'zoneredundant')

if high_availability_enabled and zonal_resiliency_enabled:
raise ArgumentUsageError('Setting both --high-availability and --zonal-resiliency is not allowed. '
'To proceed, set only --zonal-resiliency.')

if instance:
tier = instance.sku.tier if tier is None else tier
zone = instance.availability_zone if zone is None else zone

if high_availability_enabled:
if tier.lower() == 'burstable':
raise ArgumentUsageError('High availability is not supported for the Burstable tier.')
if single_az and high_availability_zone_redundant:
raise ArgumentUsageError('This location has a single availability zone. '
'Zone-redundant high availability is not supported for this location.')

if zonal_resiliency_enabled:
if tier.lower() == 'burstable':
raise ArgumentUsageError('High availability is not supported for the Burstable tier.')
Expand All @@ -373,8 +360,8 @@ def _pg_high_availability_validator(high_availability, zonal_resiliency, allow_s
'To proceed, set --allow-same-zone.')

if standby_availability_zone:
if not high_availability_zone_redundant and not zonal_resiliency_enabled:
raise ArgumentUsageError('To set --standby-availability-zone, enable --zonal-resiliency.')
if not zonal_resiliency_enabled:
raise ArgumentUsageError('To set --standby-zone, enable --zonal-resiliency.')
if zone == standby_availability_zone:
raise ArgumentUsageError('Your server is in availability zone {}. '
'The standby availability zone must be different from the server zone.'
Expand Down
Loading