sql: support in-place storage shrink for google_sql_database_instance#18327
sql: support in-place storage shrink for google_sql_database_instance#18327DrFaust92 wants to merge 1 commit into
Conversation
Reducing `disk_size` (with `disk_autoresize` disabled) previously forced the instance to be recreated. Use the dedicated Instances.PerformDiskShrink operation to shrink storage in place instead, with a pre-flight GetDiskShrinkConfig check that returns a clear error when the requested size is below the instance's minimum shrinkable size.
|
Googlers: For automatic test runs see go/terraform-auto-test-runs. @shuyama1, a repository maintainer, has been assigned to review your changes. If you have not received review feedback within 2 business days, please leave a comment on this PR asking them to take a look. You can help make sure that review is quick by doing a self-review and by running impacted tests locally. |
|
Hi there, I'm the Modular magician. I've detected the following information about your changes for commit ef335c3: Diff reportYour PR generated the following diffs in downstream repositories:
Test reportAnalytics
Affected Service Packages
Step 1: Replaying Mode Action takenFound 1 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
View the replaying VCR build log Step 2: Recording Mode
🟢 All tests passed! View the recording VCR build log or the debug logs folder for detailed results. @DrFaust92, @shuyama1 VCR tests complete for ef335c3! |
Summary
Reducing
disk_sizeongoogle_sql_database_instance(withdisk_autoresizedisabled) previously forced the instance to be recreated — a destructive operation for a data disk. Cloud SQL now supports reducing storage in place via the dedicatedInstances.PerformDiskShrinkoperation (GA for MySQL/PostgreSQL, and available for SQL Server).This change wires that up:
diskSizeCutomizeDiffno longer callsForceNewon a shrink; the shrink is kept as an in-place update.disk_sizedecrease is carried out withProjects.Instances.PerformDiskShrink(the settings update keeps the current size, so it's a no-op for disk).GetDiskShrinkConfigcall returns a clear error when the requested size is below the instance's current minimum shrinkable size, instead of letting the shrink operation start and then fail.disk_sizefield docs updated.Increases are unaffected (still applied via the settings update). A shrink with
disk_autoresizeenabled continues to be ignored, as before.Tests
Acceptance tests were run against real GCP:
TestAccSqlDatabaseInstance_storageShrink(new) — creates a 100GB instance and shrinks it in place to 90GB, asserting the disk size and that the instance is not recreated (same ID). PASSTestAccSqlDatabaseInstance_DiskSizeAutoResizeWithDiskSize(updated) — the step that previously asserted a forced recreate now asserts an in-place update plan (PlanOnly+ExpectNonEmptyPlan). PASSNote: storage shrink is not supported on shared-core machine types, so the new test uses a
db-custom-*tier.Release Note