@@ -92,6 +92,13 @@ def retention_validator(ns):
9292 raise CLIError ('incorrect usage: --backup-retention. Range is 7 to 35 days.' )
9393
9494
95+ def node_count_validator (ns ):
96+ if ns .cluster_size is not None :
97+ val = ns .cluster_size
98+ if not 1 <= int (val ) <= 10 :
99+ raise CLIError ('incorrect usage: --node-count. Range is 1 to 10 for an elastic cluster.' )
100+
101+
95102# Validates if a subnet id or name have been given by the user. If subnet id is given, vnet-name should not be provided.
96103def validate_subnet (cmd , namespace ):
97104
@@ -301,7 +308,7 @@ def pg_arguments_validator(db_context, location, tier, sku_name, storage_gb, ser
301308 version = None , instance = None , geo_redundant_backup = None ,
302309 byok_identity = None , byok_key = None , backup_byok_identity = None , backup_byok_key = None ,
303310 auto_grow = None , performance_tier = None ,
304- storage_type = None , iops = None , throughput = None ):
311+ storage_type = None , iops = None , throughput = None , create_cluster = None , cluster_size = None ):
305312 validate_server_name (db_context , server_name , 'Microsoft.DBforPostgreSQL/flexibleServers' )
306313 is_create = not instance
307314 if is_create :
@@ -317,6 +324,8 @@ def pg_arguments_validator(db_context, location, tier, sku_name, storage_gb, ser
317324 sku_info = {k .lower (): v for k , v in sku_info .items ()}
318325 single_az = list_location_capability_info ['single_az' ]
319326 geo_backup_supported = list_location_capability_info ['geo_backup_supported' ]
327+ _cluster_validator (create_cluster , cluster_size , auto_grow , geo_redundant_backup , version , tier ,
328+ byok_identity , byok_key , backup_byok_identity , backup_byok_key , instance )
320329 _network_arg_validator (subnet , public_access )
321330 _pg_tier_validator (tier , sku_info ) # need to be validated first
322331 if tier is None and instance is not None :
@@ -341,6 +350,24 @@ def pg_arguments_validator(db_context, location, tier, sku_name, storage_gb, ser
341350 pg_byok_validator (byok_identity , byok_key , backup_byok_identity , backup_byok_key , geo_redundant_backup , instance )
342351
343352
353+ def _cluster_validator (create_cluster , cluster_size , auto_grow , geo_redundant_backup , version , tier ,
354+ byok_identity , byok_key , backup_byok_identity , backup_byok_key , instance ):
355+ if create_cluster == 'ElasticCluster' or (instance and instance .cluster and instance .cluster .cluster_size > 0 ):
356+ if instance is None and cluster_size is None :
357+ cluster_size = 2
358+ if instance is None and version == '17' :
359+ raise ValidationError ("PostgreSQL version 17 is currently not supported for elastic cluster." )
360+
361+ if auto_grow and auto_grow .lower () != 'disabled' :
362+ raise ValidationError ("Storage Auto-grow is currently not supported for elastic cluster." )
363+ if geo_redundant_backup and geo_redundant_backup .lower () != 'disabled' :
364+ raise ValidationError ("Geo-redundancy is currently not supported for elastic cluster." )
365+ if byok_identity or byok_key or backup_byok_identity or backup_byok_key :
366+ raise ValidationError ("Data encryption is currently not supported for elastic cluster." )
367+ if tier == 'Burstable' :
368+ raise ValidationError ("Burstable tier is currently not supported for elastic cluster." )
369+
370+
344371def _pg_storage_validator (storage_gb , sku_info , tier , storage_type , iops , throughput , instance ):
345372 is_ssdv2 = storage_type == "PremiumV2_LRS" or instance is not None and instance .storage .type == "PremiumV2_LRS"
346373 # storage_gb range validation
0 commit comments