Skip to content

[Bug]: The provider does not inform Terraform about changes in instance_ids when updating K8s versions or modifying pool count #1852

@gasalomo-akamai

Description

@gasalomo-akamai

Terraform Version

Terraform v1.11.4 on darwin_arm64

Linode Provider Version

version = "2.37.0"

Effected Terraform Resources

linode_lke_cluster

Terraform Config Files

resource "linode_lke_cluster" "lke_cluster" {
  label       = var.cluster_name
  k8s_version = var.k8s_version
  region      = var.region

  control_plane {
    high_availability = true
  }

  pool {
    type  = var.node_type
    count = var.node_count
  }
}

Config with dependency on the instance_ids of the nodes:
https://gist.github.com/gasalomo-github/8998b88445380fe58c2c5680aa66afe8

Debug Output

$ TF_LINODE=DEBUG  LINODE_DEBUG=1 terraform plan
module.lke_cluster.linode_lke_cluster.lke_cluster: Refreshing state... [id=...]

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:

  # linode_lke_cluster.lke_cluster will be updated in-place
  ~ resource "linode_lke_cluster" "lke_cluster" {
        id            = "<cluster-id>"
      ~ k8s_version   = "1.31" -> "1.32"
        tags          = []
        # (6 unchanged attributes hidden)

        # (2 unchanged blocks hidden)
    }

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

Panic Output

No response

Expected Behavior

upgrade:

$terraform plan
...
 # linode_lke_cluster.lke_cluster will be updated in-place
  ~ resource "linode_lke_cluster" "lke_cluster" {
        id            = <cluster-id>
      ~ k8s_version   = "1.31" -> "1.32"
        tags          = []
        # (6 unchanged attributes hidden)

      ~ pool {
            id              = <pool-id>
          ~ nodes           = [
              ~ {
                    id          = <node-id>
                    instance_id     = (known after apply)
                },
             ...
            ] 
            # (3 unchanged attributes hidden)
        }
        # (1 unchanged block hidden)
    }

pool count change:

$terraform plan
...
 # linode_lke_cluster.lke_cluster will be updated in-place
  ~ resource "linode_lke_cluster" "lke_cluster" {
        id            = <cluster-id>
        tags          = []
        # (6 unchanged attributes hidden)

      ~ pool {
            id              = <pool-id>
          ~ count           = 1 -> 2
          ~ nodes           = (known after apply)
             ...
            ] 
            # (2 unchanged attributes hidden)
        }
        # (1 unchanged block hidden)
    }

The reason this is an issue, is because terraform does not know to change other resources that are dependent on the "instance_id" like for example "linode_firewall_device".

Actual Behavior

Upgrade:

$terraform plan
...
 # linode_lke_cluster.lke_cluster will be updated in-place
  ~ resource "linode_lke_cluster" "lke_cluster" {
       id            = <cluster-id>
      ~ k8s_version   = "1.31" -> "1.32"
        tags          = []
        # (6 unchanged attributes hidden)

        # (2 unchanged blocks hidden)
    }

Pool count change:

$terraform plan
...
 # linode_lke_cluster.lke_cluster will be updated in-place
  ~ resource "linode_lke_cluster" "lke_cluster" {
        id            = <cluster-id>
        tags          = []
        # (7 unchanged attributes hidden)

      ~ pool {
          ~ count           = 1 -> 2
            id              = <pool-id>
            tags            = []
            # (4 unchanged attributes hidden)
        }

        # (1 unchanged block hidden)
    }


### Steps to Reproduce

# Upgrade:
1. Create an lke cluster with the k8s_version being one before the latest version.
2. Run plan with latest k8s_version using terraform.
--- 
# Pool count change:
1. Create a cluster with a pool with count =1.
2. Run plan for count =2

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugissues that report a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions