Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failing test(s): TestAccSqlDatabaseInstance_Edition_Downgrade #20010

Comments

@SarahFrench
Copy link
Member

SarahFrench commented Oct 24, 2024

Impacted tests

  • TestAccSqlDatabaseInstance_Edition_Downgrade

Affected Resource(s)

  • google_sql_database_instance

Failure rates

  • 100% since 2024-09-04

Message(s)

------- Stdout: -------
=== RUN   TestAccSqlDatabaseInstance_Edition_Downgrade
=== PAUSE TestAccSqlDatabaseInstance_Edition_Downgrade
=== CONT  TestAccSqlDatabaseInstance_Edition_Downgrade
    resource_sql_database_instance_test.go:1818: Step 3/4 error: Error running apply: exit status 1
        Error: Error, failed to update instance settings for : googleapi: Error 400: Invalid request: Only ENTERPRISE PLUS edition supports data cache.., invalid
          with google_sql_database_instance.instance,
          on terraform_plugin_test.tf line 3, in resource "google_sql_database_instance" "instance":
           3: resource "google_sql_database_instance" "instance" {
--- FAIL: TestAccSqlDatabaseInstance_Edition_Downgrade (525.33s)
FAIL
------- Stdout: -------
=== RUN   TestAccSqlDatabaseInstance_Edition_Downgrade
=== PAUSE TestAccSqlDatabaseInstance_Edition_Downgrade
=== CONT  TestAccSqlDatabaseInstance_Edition_Downgrade
    resource_sql_database_instance_test.go:1792: Step 1/4 error: After applying this test step, the plan was not empty.
        stdout:
        Terraform used the selected providers to generate the following execution
        plan. Resource actions are indicated with the following symbols:
          ~ update in-place
        Terraform will perform the following actions:
          # google_sql_database_instance.instance will be updated in-place
          ~ resource "google_sql_database_instance" "instance" {
                id                             = "tf-test-enterprise-downgrade-txcfd1ya7y"
                name                           = "tf-test-enterprise-downgrade-txcfd1ya7y"
                # (18 unchanged attributes hidden)
              ~ settings {
                    # (17 unchanged attributes hidden)
                  - data_cache_config {
                      - data_cache_enabled = true -> null
                    }
                    # (3 unchanged blocks hidden)
                }
            }
        Plan: 0 to add, 1 to change, 0 to destroy.
--- FAIL: TestAccSqlDatabaseInstance_Edition_Downgrade (346.01s)
FAIL

Nightly build test history

https://hashicorp.teamcity.com/test/-2885316322015289714?currentProjectId=TerraformProviders_GoogleCloud_GOOGLE_NIGHTLYTESTS&expandTestHistoryChartSection=true

b/375381759

@melinath
Copy link
Collaborator

This is also failing on all PRs.

melinath added a commit to GoogleCloudPlatform/magic-modules that referenced this issue Oct 24, 2024
This is failing on all PRs; skipping until resolved.
@SarahFrench
Copy link
Member Author

SarahFrench commented Oct 25, 2024

There were no changes to the test at the start of September when the test started failing, same is true for the resource.

So looks like an API-side change?

The failing test (code) doesn't set a value for data_cache_config. Note: that field is optional + computed, hence why it's affecting the test despite not being in the config.


More info here: https://cloud.google.com/sql/docs/postgres/upgrade-cloud-sql-instance-to-enterprise-plus-in-place#switch-to-enterprise

Note: Cloud SQL disables the data cache automatically when you change an instance from Cloud SQL Enterprise Plus edition to Cloud SQL Enterprise edition.

@SarahFrench
Copy link
Member Author

SarahFrench commented Oct 25, 2024

In the test's logs I can see that the PUT request to change the edition to "ENTERPRISE" includes a dataCacheConfig block, which I believe is causing the error. That field is optional + computed, hence why it's present despite not being in the config. It's presumably set to enabled by default when the resource is first created with edition=ENTERPRISE_PLUS, and then that value persists after config is changed to edition=ENTERPRISE

---[ REQUEST ]---------------------------------------
PUT /sql/v1beta4/projects/PROEJCT_ID/instances/tf-test-enterprise-downgrade-afq6ij34d9?alt=json&prettyPrint=false HTTP/1.1
Host: sqladmin.googleapis.com
User-Agent: google-api-go-client/0.5 Terraform/1.8.3 (+https://www.terraform.io) Terraform-Plugin-SDK/2.33.0 terraform-provider-google/dev6
Content-Length: 884
Content-Type: application/json
X-Goog-Api-Client: gl-go/1.21.13 gdcl/0.201.0
Accept-Encoding: gzip

{
 "instanceType": "CLOUD_SQL_INSTANCE",
 "settings": {
  "activationPolicy": "ALWAYS",
  "availabilityType": "ZONAL",
  "backupConfiguration": {
   "backupRetentionSettings": {
    "retainedBackups": 15,
    "retentionUnit": "COUNT"
   },
   "binaryLogEnabled": false,
   "enabled": false,
   "pointInTimeRecoveryEnabled": false,
   "startTime": "11:00",
   "transactionLogRetentionDays": 7
  },
  "connectorEnforcement": "NOT_REQUIRED",
  "dataCacheConfig": {
   "dataCacheEnabled": true
  },
  "dataDiskSizeGb": "10",
  "dataDiskType": "PD_SSD",
  "edition": "ENTERPRISE",
  "enableDataplexIntegration": false,
  "enableGoogleMlIntegration": false,
  "ipConfiguration": {
   "enablePrivatePathForGoogleCloudServices": false,
   "ipv4Enabled": true,
   "requireSsl": null,
   "serverCaMode": "GOOGLE_MANAGED_INTERNAL_CA",
   "sslMode": "ALLOW_UNENCRYPTED_AND_ENCRYPTED"
  },
  "locationPreference": {
   "zone": "us-east1-b"
  },
  "pricingPlan": "PER_USE",
  "settingsVersion": "6",
  "storageAutoResize": true,
  "tier": "db-custom-2-13312"
 }
}

We should include a CustomizeDiff, etc, to set a new computed value for data_cache_config and its child fields if the edition is being changed from "ENTERPRISE_PLUS" to "ENTERPRISE". This then raises the question of what the behaviour should be if a user upgrades an existing "ENTERPRISE" to "ENTERPRISE_PLUS".

Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.