terraform-provider-aiven icon indicating copy to clipboard operation
terraform-provider-aiven copied to clipboard

PG Major upgrade exit when there's pending maintenance updates

Open runwuf opened this issue 10 months ago • 0 comments

What happened?

PG allows major version upgrade with

  pg_user_config {
    pg_version = 16
  }

However, if there are pending maintenance updates, terraform would exit without performing the upgrade.

If there's no maintenance updates, upgrade performed successfully

resource "aiven_pg" "pg" {
  ~ resource "aiven_pg" "pg" {
        id                      = "felixwu-demo/cdc-pg"
        # (20 unchanged attributes hidden)

      ~ pg_user_config {
          ~ pg_version                = "15" -> "16"
            # (12 unchanged attributes hidden)

            # (2 unchanged blocks hidden)
        }

        # (1 unchanged block hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

aiven_pg.pg: Modifying... [id=felixwu-demo/cdc-pg]
...
aiven_pg.pg: Still modifying... [id=felixwu-demo/cdc-pg, 1m40s elapsed]
aiven_pg.pg: Modifications complete after 1m48s [id=felixwu-demo/cdc-pg]

Apply complete! Resources: 0 added, 1 changed, 0 destroyed.

When attempting downgrade, it exits

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:

  # aiven_pg.pg will be updated in-place
  ~ resource "aiven_pg" "pg" {
        id                      = "felixwu-demo/cdc-pg"
        # (20 unchanged attributes hidden)

      ~ pg_user_config {
          ~ pg_version                = "16" -> "15"
            # (12 unchanged attributes hidden)

            # (2 unchanged blocks hidden)
        }

        # (1 unchanged block hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

aiven_pg.pg: Modifying... [id=felixwu-demo/cdc-pg]
aiven_pg.pg: Still modifying... [id=felixwu-demo/cdc-pg, 10s elapsed]
╷
│ Error: PG service upgrade check error, version upgrade from 16 to 15, result: Internal Error. Please contact support (data dir already exists).
│
│   with aiven_pg.pg,
│   on cdc.tf line 1, in resource "aiven_pg" "pg":
│    1: resource "aiven_pg" "pg" {

What did you expect to happen?

Consistent behaviour - if PG major version upgrade is allowed in terraform provider, it should proceed regardless if there's maintenance updates or not, it should not exit if there are maintenance updates. Or it should stop allowing to both upgrade and downgrade.

What else do we need to know?

Not sure how best to address maintenance updates & maintenance window restrictions.

runwuf avatar Mar 26 '24 22:03 runwuf