volcengine / terraform-provider-volcengine

Mozilla Public License 2.0
27 stars 10 forks source link

Bug: After creating a VKE with Terraform and specifying a version, there will still be diff #58

Closed Dup4 closed 1 year ago

Dup4 commented 1 year ago

When I create a VKE instance via terraform, I specify the version number as 1.24, but the instance that is created has the version number v1.24.8-vke.4 and when I execute terraform plan again, it triggers a re-creation of the instance, which should not be expected.

image

image

If I specify the exact version number, it will show NotSupported.KubernetesVersion like the image above.

resource "volcengine_vke_cluster" "bytesbc_boe" {
  name                      = "bytesbc-boe"
  description               = "ByteSBC BOE"
  kubernetes_version        = "1.24"
  delete_protection_enabled = true

  cluster_config {
    api_server_public_access_enabled = true
    api_server_public_access_config {
      public_access_network_config {
        billing_type = "PostPaidByTraffic"
        bandwidth    = 200
      }
    }

    # API Server subnet
    # Not Support cn-shanghai-c AZ
    subnet_ids = [
      volcengine_subnet.bytesbc_boe_subnet_infra_a.id,
      volcengine_subnet.bytesbc_boe_subnet_infra_b.id,
    ]

    resource_public_access_default_enabled = false
  }

  pods_config {
    pod_network_mode = "VpcCniShared"

    vpc_cni_config {
      vpc_id = volcengine_vpc.bytesbc_boe.id

      subnet_ids = [
        volcengine_subnet.bytesbc_boe_subnet_pod_a.id,
        volcengine_subnet.bytesbc_boe_subnet_pod_b.id,
      ]
    }
  }

  services_config {
    service_cidrsv4 = ["192.168.0.0/16"]
  }
}

I used the above configuration.

xuyaming0800 commented 1 year ago

hi,what's the release version of terraform-provider-volcengine you use? We fixed this bug in oct 2022.please update version and try

Dup4 commented 1 year ago

hi,what's the release version of terraform-provider-volcengine you use? We fixed this bug in oct 2022.please update version and try

terraform {
  required_providers {
    volcengine = {
      source  = "volcengine/volcengine"
      version = "0.0.47"
    }
  }

  required_version = ">= 1.3.0"
}
Dup4 commented 1 year ago

I upgraded to the latest version, i.e. 0.0.49, but the problem persists, I have not changed a single line of my terraform code, but there is diff.

image

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following
symbols:
-/+ destroy and then create replacement

Terraform will perform the following actions:

  # module.bytesbc-boe.volcengine_vke_cluster.bytesbc_boe must be replaced
-/+ resource "volcengine_vke_cluster" "bytesbc_boe" {
      ~ eip_allocation_id         = "eip-3qecv9i03yvwg7prml01jhif9" -> (known after apply)
      ~ id                        = "ccfl45k7qtofjm6lh6c4g" -> (known after apply)
      + kubeconfig_private        = (known after apply)
      + kubeconfig_public         = (known after apply)
      ~ kubernetes_version        = "v1.24.8-vke.4" -> "1.24"
        name                      = "bytesbc-boe"
        # (2 unchanged attributes hidden)

      ~ pods_config {
            # (1 unchanged attribute hidden)

          ~ vpc_cni_config {
              + vpc_id     = "vpc-5gexv9f2rz7k73inqkau79zr" # forces replacement
                # (1 unchanged attribute hidden)
            }
        }

        # (2 unchanged blocks hidden)
    }

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

Wait, is it possible that the diff is not caused by kubernetes_version but by pods_config.vpc_cni_config.vpc_cni_config?

But I haven't changed the configuration of pods_config.vpc_cni_config.vpc_cni_config.

  pods_config {
    pod_network_mode = "VpcCniShared"

    vpc_cni_config {
      vpc_id = volcengine_vpc.bytesbc_boe.id

      subnet_ids = [
        volcengine_subnet.bytesbc_boe_subnet_pod_a.id,
        volcengine_subnet.bytesbc_boe_subnet_pod_b.id,
      ]
    }
  }

For reference, the configuration of pods_config is in the code above.

zpp12354321 commented 1 year ago

hi, could you help to check whether your vpc_id = volcengine_vpc.bytesbc_boe.id is empty string?

Dup4 commented 1 year ago

hi, could you help to check whether your vpc_id = volcengine_vpc.bytesbc_boe.id is empty string?

How to check?

zpp12354321 commented 1 year ago

hi, could you help to check whether your vpc_id = volcengine_vpc.bytesbc_boe.id is empty string?

How to check?

in the terraform.tfstate file, you can get the vpc_id info

Dup4 commented 1 year ago

hi, could you help to check whether your vpc_id = volcengine_vpc.bytesbc_boe.id is empty string?

How to check?

in the terraform.tfstate file, you can get the vpc_id info

Yes, It's empty.

    {
      "module": "module.bytesbc-boe",
      "mode": "managed",
      "type": "volcengine_vke_cluster",
      "name": "bytesbc_boe",
      "provider": "module.bytesbc-boe.provider[\"registry.terraform.io/volcengine/volcengine\"]",
      "instances": [
        {
          "schema_version": 0,
          "attributes": {
            "client_token": null,
            "cluster_config": [
              {
                "api_server_public_access_config": [
                  {
                    "public_access_network_config": [
                      {
                        "bandwidth": 200,
                        "billing_type": "PostPaidByTraffic"
                      }
                    ]
                  }
                ],
                "api_server_public_access_enabled": true,
                "resource_public_access_default_enabled": false,
                "subnet_ids": [
                  "subnet-3qeav4as0n85c7prml1lf22om",
                  "subnet-5gexvx3g4mww73inqlqbfu30"
                ]
              }
            ],
            "delete_protection_enabled": true,
            "description": "ByteSBC BOE",
            "eip_allocation_id": "eip-3qecv9i03yvwg7prml01jhif9",
            "id": "ccfl45k7qtofjm6lh6c4g",
            "kubeconfig_private": null,
            "kubeconfig_public": null,
            "kubernetes_version": "v1.24.8-vke.4",
            "name": "bytesbc-boe",
            "pods_config": [
              {
                "flannel_config": [],
                "pod_network_mode": "VpcCniShared",
                "vpc_cni_config": [
                  {
                    "subnet_ids": [
                      "subnet-22jzns8o3eio07r2qr0xkgm5f",
                      "subnet-3qeav3yxtywao7prml0g1l6d4"
                    ],
                    "vpc_id": ""
                  }
                ]
              }
            ],
            "services_config": [
              {
                "service_cidrsv4": [
                  "192.168.0.0/16"
                ]
              }
            ],
            "tags": [],
            "timeouts": null
          },
          "sensitive_attributes": [],
          "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjozNjAwMDAwMDAwMDAwLCJkZWxldGUiOjM2MDAwMDAwMDAwMDAsInVwZGF0ZSI6MzYwMDAwMDAwMDAwMH19",
          "dependencies": [
            "module.bytesbc-boe.volcengine_subnet.bytesbc_boe_subnet_infra_a",
            "module.bytesbc-boe.volcengine_subnet.bytesbc_boe_subnet_infra_b",
            "module.bytesbc-boe.volcengine_subnet.bytesbc_boe_subnet_pod_a",
            "module.bytesbc-boe.volcengine_subnet.bytesbc_boe_subnet_pod_b",
            "module.bytesbc-boe.volcengine_vpc.bytesbc_boe"
          ]
        }
      ]
    },
Dup4 commented 1 year ago

So it's a bug that the provider didn't store the vpc_id in the states when creating the vke cluster?

xuyaming0800 commented 1 year ago

hi, we found vke api VpcCniConfigResponse not contains VpcId: image but in vke document,we found vpcId in VpcCniConfigResponse: VGfuB7hLMa so the problem is vke ListClusters api do incompatible change

xuyaming0800 commented 1 year ago

@Dup4 we will use DiffSuppressFunc to diff vpc_id change and compatible this vke change in next version Thanks

xuyaming0800 commented 1 year ago

fix in release v0.0.50