Skip to content

Commit 5f63260

Browse files
authored
{RDBMS} Add warnings that default version for az postgres flexible-server create will be updating to PG17 in future and PG12 will be no longer supported (#30298)
* Add pg 17 support, and pg 12 warning * Update location capabilites feature support checks * style fix
1 parent de1efce commit 5f63260

File tree

3 files changed

+24
-9
lines changed

3 files changed

+24
-9
lines changed

src/azure-cli/azure/cli/command_modules/rdbms/_flexible_server_location_capabilities_util.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,20 @@ def _postgres_parse_list_capability(result):
4646
if not result:
4747
raise InvalidArgumentValueError("No available SKUs in this location")
4848

49-
offer_restricted = [feature for feature in result[0].supported_features if feature.name == "OfferRestricted"]
49+
supported_features = result[0].supported_features if result[0].supported_features is not None else []
50+
offer_restricted = [feature for feature in supported_features if feature.name == "OfferRestricted"]
51+
restricted = offer_restricted[0].status if offer_restricted else None
52+
zone_redundant = [feature for feature in supported_features if feature.name == "ZoneRedundantHa"]
53+
geo_backup = [feature for feature in supported_features if feature.name == "GeoBackup"]
5054

51-
if offer_restricted[0].status == "Enabled":
55+
if restricted == "Enabled":
5256
raise InvalidArgumentValueError("The location is restricted for provisioning of flexible servers. Please try using another region.")
5357

54-
if offer_restricted[0].status != "Disabled":
58+
if restricted != "Disabled":
5559
raise InvalidArgumentValueError("No available SKUs in this location.")
5660

57-
single_az = result[0].zone_redundant_ha_supported != "Enabled"
58-
geo_backup_supported = result[0].geo_backup_supported == "Enabled"
61+
single_az = zone_redundant[0].status != "Enabled" if zone_redundant else True
62+
geo_backup_supported = geo_backup[0].status == "Enabled" if geo_backup else False
5963

6064
tiers = result[0].supported_server_editions
6165
tiers_dict = {}

src/azure-cli/azure/cli/command_modules/rdbms/_helptext_pg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
az postgres flexible-server create --location northeurope --resource-group testGroup \\
3636
--name testserver --admin-user username --admin-password password \\
3737
--sku-name Standard_D2s_v3 --tier GeneralPurpose --public-access 153.24.26.117 --storage-size 128 \\
38-
--tags "key=value" --version 16 --high-availability ZoneRedundant --zone 1 \\
38+
--tags "key=value" --version 17 --high-availability ZoneRedundant --zone 1 \\
3939
--standby-zone 3
4040
- name: >
4141
Create a PostgreSQL flexible server using Premium SSD v2 Disks.

src/azure-cli/azure/cli/command_modules/rdbms/validators.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,8 @@ def pg_arguments_validator(db_context, location, tier, sku_name, storage_gb, ser
303303
auto_grow=None, performance_tier=None,
304304
storage_type=None, iops=None, throughput=None):
305305
validate_server_name(db_context, server_name, 'Microsoft.DBforPostgreSQL/flexibleServers')
306-
if not instance:
306+
is_create = not instance
307+
if is_create:
307308
list_location_capability_info = get_postgres_location_capability_info(
308309
db_context.cmd,
309310
location)
@@ -336,7 +337,7 @@ def pg_arguments_validator(db_context, location, tier, sku_name, storage_gb, ser
336337
_pg_storage_validator(storage_gb, sku_info, tier, storage_type, iops, throughput, instance)
337338
_pg_sku_name_validator(sku_name, sku_info, tier, instance)
338339
_pg_high_availability_validator(high_availability, standby_availability_zone, zone, tier, single_az, instance)
339-
_pg_version_validator(version, list_location_capability_info['server_versions'])
340+
_pg_version_validator(version, list_location_capability_info['server_versions'], is_create)
340341
pg_byok_validator(byok_identity, byok_key, backup_byok_identity, backup_byok_key, geo_redundant_backup, instance)
341342

342343

@@ -438,10 +439,20 @@ def _pg_storage_performance_tier_validator(performance_tier, sku_info, tier=None
438439
' Allowed values : {}'.format(storage_size, performance_tiers))
439440

440441

441-
def _pg_version_validator(version, versions):
442+
def _pg_version_validator(version, versions, is_create):
442443
if version:
443444
if version not in versions:
444445
raise CLIError('Incorrect value for --version. Allowed values : {}'.format(versions))
446+
if version == '12':
447+
logger.warning("Support for PostgreSQL 12 has officially ended. As a result, "
448+
"the option to select version 12 will be removed in the near future. "
449+
"We recommend selecting PostgreSQL 13 or a later version for "
450+
"all future operations.")
451+
452+
if is_create:
453+
# Warning for upcoming breaking change to default value of pg version
454+
logger.warning("The default value for the PostgreSQL server major version "
455+
"will be updating to 17 in the near future.")
445456

446457

447458
def _pg_high_availability_validator(high_availability, standby_availability_zone, zone, tier, single_az, instance):

0 commit comments

Comments
 (0)