Skip to content

[POSTGRESQL] az postgres flexible-server create: Block SSDv2 creation for PG version < 14#33119

Open
mattboentoro wants to merge 1 commit intoAzure:devfrom
mattboentoro:mattboentoro/block-ssdv2-for-pg-less-than-14
Open

[POSTGRESQL] az postgres flexible-server create: Block SSDv2 creation for PG version < 14#33119
mattboentoro wants to merge 1 commit intoAzure:devfrom
mattboentoro:mattboentoro/block-ssdv2-for-pg-less-than-14

Conversation

@mattboentoro
Copy link
Copy Markdown
Member

Related command
az postgres flexible-server create

Description
Block SSDv2 creation for PG version < 14

Testing Guide

❯ az postgres flexible-server create --location northeurope --resource-group mboentoro-test --name mboentoro-test-ssdv2 --version 13 --admin-user username --admin-password password --sku-name Standard_B1ms --tier GeneralPurpose --storage-type PremiumV2_LRS --storage-size 128 --iops 3000 --throughput 125                                                                                                                       
Checking the existence of the resource group 'mboentoro-test'...
Resource group 'mboentoro-test' exists ? : True 
Storage type PremiumV2_LRS is only supported for PostgreSQL version 14 and above.

History Notes

[POSTGRESQL] az postgres flexible-server create: Block SSDv2 creation for PG version < 14


This checklist is used to make sure that common guidelines for a pull request are followed.

Copilot AI review requested due to automatic review settings April 1, 2026 21:40
@azure-client-tools-bot-prd
Copy link
Copy Markdown

Validation for Azure CLI Full Test Starting...

Thanks for your contribution!

@azure-client-tools-bot-prd
Copy link
Copy Markdown

Validation for Breaking Change Starting...

Thanks for your contribution!

@yonzhan
Copy link
Copy Markdown
Collaborator

yonzhan commented Apr 1, 2026

Thank you for your contribution! We will review the pull request and get back to you soon.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 1, 2026

The git hooks are available for azure-cli and azure-cli-extensions repos. They could help you run required checks before creating the PR.

Please sync the latest code with latest dev branch (for azure-cli) or main branch (for azure-cli-extensions).
After that please run the following commands to enable git hooks:

pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates PostgreSQL flexible server argument validation to prevent using Premium SSD v2 storage (PremiumV2_LRS) when creating servers on PostgreSQL versions earlier than 14.

Changes:

  • Passes version into the storage-type validator.
  • Adds a version gate that blocks PremiumV2_LRS creation for PG major versions < 14.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +720 to +721
if version and int(version) < 14:
raise CLIError('Storage type PremiumV2_LRS is only supported for PostgreSQL version 14 and above.')
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

int(version) is evaluated before pg_version_validator runs (and before any format validation), so invalid inputs like --version foo with --storage-type PremiumV2_LRS will raise an unhandled ValueError instead of a clean CLI validation error. Consider avoiding int() here (e.g., compare against explicit supported majors like ('11','12','13') or safely parse version.split('.')[0] inside a try/except that raises CLIError), or move pg_version_validator(...) earlier so version is validated before this check.

Suggested change
if version and int(version) < 14:
raise CLIError('Storage type PremiumV2_LRS is only supported for PostgreSQL version 14 and above.')
if version:
try:
# Accept versions like "14" or "14.x" by using the major component only.
major_version = int(str(version).split('.')[0])
except (ValueError, TypeError):
raise CLIError('Invalid PostgreSQL version "{}".'.format(version))
if major_version < 14:
raise CLIError('Storage type PremiumV2_LRS is only supported for PostgreSQL version 14 and above.')

Copilot uses AI. Check for mistakes.
Comment on lines 719 to 722
if is_create_ssdv2:
if version and int(version) < 14:
raise CLIError('Storage type PremiumV2_LRS is only supported for PostgreSQL version 14 and above.')
if supported_storageV2_size is None:
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change introduces new user-facing validation behavior (blocking PremiumV2_LRS for PG < 14) but there’s no test ensuring the create command fails with the expected message for versions 11/12/13. Adding a scenario test case (similar to existing SSDv2 tests) would prevent regressions and ensure the validator is exercised.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants