linode / terraform-provider-linode

Terraform Linode provider
https://www.terraform.io/docs/providers/linode/
Mozilla Public License 2.0
202 stars 98 forks source link

fix: Allow disks to be resized/deleted on instances that have been running for > 90 days #1581

Closed lgarber-akamai closed 1 month ago

lgarber-akamai commented 2 months ago

📝 Description

This pull request resolves an issue that prevented disks from being resized and deleted on instances that have been running for more than 90 days. This is achieved by removing the booted config resolution logic from the linode_instance_disk resize logic and instead deferring it to the API during the subsequent boot.

Additionally, this PR moves the BootInstanceSync and ShutdownInstanceSync helper functions to the helper package, and adds a new WaitForInstanceNonTransientStatus helper.

✔️ How to Test

The following test steps assume you have pulled down this PR locally.

Integration Testing

make int-test PKG_NAME=linode/instance
make int-test PKG_NAME=linode/instancedisk
make int-test PKG_NAME=linode/instanceconfig

Manual Testing

  1. In a terraform-provider-linode sandbox environment (e.g. dx-devenv), apply the following configuration:
resource "linode_instance" "test" {
  label  = "test-instance"
  region = "us-mia"
  type   = "g6-nanode-1"
}

resource "linode_instance_disk" "test" {
  label     = "test"
  linode_id = linode_instance.test.id

  size  = 4000
  image = "linode/ubuntu22.04"

  root_pass = "terr4form-t3$t!!!!!!!"
}

resource "linode_instance_config" "test" {
  label     = "test"
  linode_id = linode_instance.test.id

  device {
    device_name = "sda"
    disk_id     = linode_instance_disk.test.id
  }

  root_device = "/dev/sda"
  kernel      = "linode/latest-64bit"
  booted      = true
}
  1. Ensure the apply completes successfully
  2. Change the size of the disk and re-apply the configuration.
  3. Ensure the apply completes successfully.
  4. Ensure the disk has been properly resized.