sql: support in-place storage shrink for google_sql_database_instance#18327
Open
DrFaust92 wants to merge 1 commit into
Open
sql: support in-place storage shrink for google_sql_database_instance#18327DrFaust92 wants to merge 1 commit into
DrFaust92 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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