rancher / terraform-provider-rancher2

Terraform Rancher2 provider
https://www.terraform.io/docs/providers/rancher2/
Mozilla Public License 2.0
258 stars 223 forks source link

Cannot clear rke_config.cloud_provider.openstack_config from Terraform #467

Closed bgagnon closed 3 years ago

bgagnon commented 3 years ago

Assuming this starting Terraform resource:

resource "rancher2_cluster" "default" {
  name = var.cluster_name

  rke_config {
    kubernetes_version = "v1.17.5-rancher1-1"

    cloud_provider {
      name = "openstack"
      openstack_cloud_provider {
        global {
          auth_url    = var.os_auth_url
          region      = var.os_region_name
          domain_name = "Default"
          tenant_name = var.os_tenant_name
          tenant_id   = ""
          username    = var.os_username
          password    = var.os_password
        }

        load_balancer {
          use_octavia = true
          monitor_max_retries = 0
          monitor_delay   = "0s"
          monitor_timeout = "0s"
        }
      }
    }
}

transitioning to:

resource "rancher2_cluster" "default" {
  name = var.cluster_name

  rke_config {
    kubernetes_version = "v1.17.5-rancher1-1"

    cloud_provider {
      name = "external"
    }
}

the Terraform plan is as expected, clearing every field in rke_config.cloud_provider.openstack_config:

          ~ cloud_provider {
               ~ name = "openstack" -> "external"
              - openstack_cloud_provider {
                  - block_storage {
                      - ignore_volume_az  = false -> null
                      - trust_device_path = false -> null
                    }
                  - global {
                      - auth_url    = "<redacted>" -> null
                      - domain_name = "Default" -> null
                      - region      = "<redacted>" -> null
                      - tenant_name = "<redacted>" -> null
                      - username    = (sensitive value)
                    }
                  - load_balancer {
                      - create_monitor         = false -> null
                      - manage_security_groups = false -> null
                      - monitor_delay          = "0s" -> null
                      - monitor_max_retries    = 0 -> null
                      - monitor_timeout        = "0s" -> null
                      - use_octavia            = true -> null
                    }
                  - metadata {}
                  - route {}
                }
            }

After the operation however, the API object on the Rancher side still contains the unmodified openstack_cloud_provider contents.

A subsequent terraform plan shows the exact same changes (except cloud_provider.name which sticks), creating an infinite loop.

Editing the cluster YAML from the Rancher UI is the only way I have found to strip the unwanted openstack_cloud_provider attribute block. Even so, it merely replaces the values by their default; the object sticks around.

gz#17326

bgagnon commented 3 years ago

For reference, support for external cloud provider was added in #364 and resolved #319

rawmind0 commented 3 years ago

Submitted PR #681 to fix this issue

rawmind0 commented 3 years ago

PR https://github.com/rancher/terraform-provider-rancher2/pull/681 is already merged. The fix will be included on next tf provider release.

Please, reopen issue if needed