Skip to content

[MySQL] az mysql flexible-server geo-restore: do not force source storage redundancy on target - #33814

Open
a0x1ab with Copilot wants to merge 2 commits into
devfrom
copilot/fix-geo-restore-ha-mysql-issue
Open

[MySQL] az mysql flexible-server geo-restore: do not force source storage redundancy on target#33814
a0x1ab with Copilot wants to merge 2 commits into
devfrom
copilot/fix-geo-restore-ha-mysql-issue

Conversation

Copilot AI commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Related command
az mysql flexible-server geo-restore

Description
Geo-restore from Zone-Redundant HA sources can fail in paired regions that do not support ZRS (e.g., UK West) because CLI was sending source storage_redundancy into target create payload.
This change stops pinning target storage redundancy to source value, so geo-restore can proceed with region-supported redundancy.

  • Root cause

    • flexible_server_georestore copied source_server_object.storage.storage_redundancy into models.Storage(...).
  • Code change

    • Removed storage_redundancy from geo-restore storage payload construction in:
      • /src/azure-cli/azure/cli/command_modules/mysql/custom.py
    • Behavior now aligns with service-side selection for target-region-compatible storage redundancy.
  • Regression coverage

    • Added focused unit test:
      • /src/azure-cli/azure/cli/command_modules/mysql/tests/latest/test_mysql_flexible_server_georestore.py
    • Validates geo-restore path does not pass storage_redundancy from source.
# before
storage = models.Storage(..., storage_redundancy=source_server_object.storage.storage_redundancy)

# after
storage = models.Storage(...)

Testing Guide
Example command (paired-region DR path):

az mysql flexible-server geo-restore \
  -g <target-rg> \
  -n <target-server> \
  --source-server <source-server-or-id> \
  --location ukwest

Optional explicit sizing/SKU overrides (still supported):

az mysql flexible-server geo-restore \
  -g <target-rg> -n <target-server> \
  --source-server <source-server-or-id> \
  --location ukwest \
  --tier GeneralPurpose \
  --sku-name Standard_D2ds_v4 \
  --storage-size 64

History Notes
[MySQL] az mysql flexible-server geo-restore: stop forcing source storage redundancy in target create payload to avoid non-ZRS region restore failures


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

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI changed the title [WIP] Fix geo-restore failure from Zone-Redundant HA MySQL server [MySQL] az mysql flexible-server geo-restore: do not force source storage redundancy on target Jul 30, 2026
Copilot AI requested a review from a0x1ab July 30, 2026 13:05
@azure-client-tools-agent

Copy link
Copy Markdown

Live test results — azdev test --live --series (changed test files only)

PASS

Selectors: test_mysql_flexible_server_georestore (module)
PR head ref: copilot/fix-geo-restore-ha-mysql-issue
PR head sha: 7671d31697c6539bf176435a383e12ed16618b5f
PR base ref: dev
New test files in PR: true

Changed test files run
src/azure-cli/azure/cli/command_modules/mysql/tests/latest/test_mysql_flexible_server_georestore.py

New test files
src/azure-cli/azure/cli/command_modules/mysql/tests/latest/test_mysql_flexible_server_georestore.py

Workflow run: https://github.com/Azure/issue-sentinel/actions/runs/30545506270

Last 80 lines of azdev output

=============
| Run Tests |
=============


=====================
| Discovering Tests |
=====================

/home/runner/work/issue-sentinel/issue-sentinel/azure-cli/src/azure-cli/azure/cli/command_modules/identity/tests/latest/test_identity.py:18: SyntaxWarning: invalid escape sequence '\{'
  'resource_restriction_compute': '\{"providers":\["Microsoft.Compute"\]\}',
/home/runner/work/issue-sentinel/issue-sentinel/azure-cli/src/azure-cli/azure/cli/command_modules/identity/tests/latest/test_identity.py:19: SyntaxWarning: invalid escape sequence '\{'
  'resource_restriction_empty': '\{"providers":\[\]\}'
/home/runner/work/issue-sentinel/issue-sentinel/azure-cli/src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_vm_commands.py:13533: SyntaxWarning: invalid escape sequence '\]'
  self.cmd('vmss application set -g {rg} -n {vmss} --app-version-ids {vid1} {vid2} --enable-automatic-upgrade True\]', checks=[

test index updated: /home/runner/.azdev/env_config/home/runner/work/issue-sentinel/issue-sentinel/.venv/test_index/latest.json

Test on modules: test_mysql_flexible_server_georestore

WARNING: RUNNING TESTS LIVE
The tests are set to run against current profile "latest"
============================= test session starts ==============================
platform linux -- Python 3.12.13, pytest-9.1.1, pluggy-1.6.0 -- /home/runner/work/issue-sentinel/issue-sentinel/.venv/bin/python
cachedir: .pytest_cache
rootdir: /home/runner/work/issue-sentinel/issue-sentinel/azure-cli/src/azure-cli
plugins: xdist-3.8.0, forked-1.6.0
collecting ... collected 1 item

azure-cli/src/azure-cli/azure/cli/command_modules/mysql/tests/latest/test_mysql_flexible_server_georestore.py::FlexibleServerGeoRestoreUnitTest::test_georestore_does_not_force_source_storage_redundancy PASSED [100%]

- generated xml file: /home/runner/work/issue-sentinel/issue-sentinel/test-output/results.xml -
============================== 1 passed in 0.37s ===============================

Posted by agent-assist live-test workflow.

@azure-client-tools-agent azure-client-tools-agent Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Live Test & CI Pass

All checks have passed and the live tests completed successfully. Marking this PR ready for review.


Posted by agent-assist (autonomous bug-fix pipeline).

@azure-client-tools-agent
azure-client-tools-agent Bot marked this pull request as ready for review July 30, 2026 15:08
@azure-client-tools-agent
azure-client-tools-agent Bot requested a review from a team as a code owner July 30, 2026 15:08
Copilot AI review requested due to automatic review settings July 30, 2026 15:08
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot could not run the full agentic suite for this review because it was automatically requested on a bot-authored pull request. Request a review from Copilot under Reviewers to retry with the full agentic suite. Improved support for bot-authored pull requests is coming soon.

Updates MySQL flexible server GeoRestore to avoid forcing the source server’s storage redundancy setting onto the restored server, and adds a unit test to validate this behavior.

Changes:

  • Removed storage_redundancy propagation when constructing models.Storage in flexible_server_georestore.
  • Added a unit test ensuring GeoRestore does not pass storage_redundancy into the Storage model.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/azure-cli/azure/cli/command_modules/mysql/custom.py Stops passing storage_redundancy from source server storage into GeoRestore parameters.
src/azure-cli/azure/cli/command_modules/mysql/tests/latest/test_mysql_flexible_server_georestore.py Adds a unit test asserting storage_redundancy is not provided during GeoRestore.

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

Comment on lines +15 to +33
@patch('azure.cli.command_modules.mysql.custom.sdk_no_wait')
@patch('azure.cli.command_modules.mysql.custom.resolve_poller')
@patch('azure.cli.command_modules.mysql.custom.flexible_server_provision_network_resource')
@patch('azure.cli.command_modules.mysql.custom._determine_iops')
@patch('azure.cli.command_modules.mysql.custom.get_identity_and_data_encryption')
@patch('azure.cli.command_modules.mysql.custom.validate_server_name')
@patch('azure.cli.command_modules.mysql.custom.get_mysql_list_skus_info')
@patch('azure.cli.command_modules.mysql.custom.get_mysql_flexible_management_client_by_sub')
@patch('azure.cli.command_modules.mysql.custom.parse_resource_id')
@patch('azure.cli.command_modules.mysql.custom.is_valid_resource_id')
@patch('azure.cli.command_modules.mysql.custom.models.ServerForUpdate')
@patch('azure.cli.command_modules.mysql.custom.models.Server')
@patch('azure.cli.command_modules.mysql.custom.models.MySQLServerSku')
@patch('azure.cli.command_modules.mysql.custom.models.Backup')
@patch('azure.cli.command_modules.mysql.custom.models.Storage')
def test_georestore_does_not_force_source_storage_redundancy(
self, storage_cls, backup_cls, sku_cls, server_cls, server_update_cls, is_valid_resource_id,
parse_resource_id, get_mgmt_client_by_sub, get_list_skus_info, validate_server_name,
get_identity_and_data_encryption, determine_iops, provision_network_resource, resolve_poller, sdk_no_wait):
Comment on lines +82 to +83
if __name__ == '__main__':
unittest.main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Auto-Assign Auto assign by bot

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Geo-restore from Zone-Redundant HA MySQL Flexible Server to paired region (UK West) fails with HaNotSupportedForLocationNotSupportZRS

3 participants