hashicorp / terraform-provider-google

Terraform Provider for Google Cloud Platform
https://registry.terraform.io/providers/hashicorp/google/latest/docs
Mozilla Public License 2.0
2.36k stars 1.75k forks source link

Fix edition downgrade failure for an ENTERPRISE_PLUS instance with da… #20393

Closed modular-magician closed 2 days ago

modular-magician commented 2 days ago

Recently there was an API change to enable data cache by default for ENTERPRISE_PLUS edition (both MySQL and Postgres) instances. When data_cache_config was not a computed attribute this resulted in acceptance test failures that were fixed in https://github.com/GoogleCloudPlatform/magic-modules/pull/12096.

Now that data_cache_config is computed, it stays in the resource state after a downgrade even though data_cache_config is cleared from the instance metadata. This is a consequence of performing a PATCH (for edition upgrade / downgrade) followed by an UPDATE while ignoring the change in CloudSQL instance settings from the PATCH operation. The downgrade implicitly unsets the data cache config in the API as it is not allowed to be used with ENTERPRISE edition.

This PR fixes this issue (edition downgrade failure for an ENTERPRISE_PLUS instance with data cache enabled) by persisting the data_cache_config received after the PATCH operation for edition upgrade / downgrade. Also fixes https://github.com/hashicorp/terraform-provider-google/issues/20010 as TestAccSqlDatabaseInstance_Edition_Downgrade can now run.

b/375381759

I acknowledge that I have:

Release Note Template for Downstream PRs (will be copied)

sql: fixed edition downgrade failure for an `ENTERPRISE_PLUS` instance with data cache enabled.

Derived from https://github.com/GoogleCloudPlatform/magic-modules/pull/12289