kyma-incubator / terraform-provider-kind

Terraform Provider for kind (Kubernetes IN Docker)
Apache License 2.0
80 stars 44 forks source link

Error applying when specifying network configuration #31

Closed rally-bot closed 4 years ago

rally-bot commented 4 years ago

it seems that configuring a kind cluster with any network configuration defined at all terraform will crash when attempting to apply.

take, for example, this simple resource definition with an empty network configuration:

resource "kind_cluster" "default" {
  name = "testing"
  wait_for_ready = true

  kind_config {
    api_version = var.kind_api_version
    kind = "Cluster"

    networking {}

    node {
      role = "control-plane"
    }
  }
}

despite retrying with multiple arrangements of networking configuration values it consistently crashes on every attempt to apply. an interesting thing to note is that when creating the plan, it seems to always inject the optional disable_default_cni argument:


module.local_kind_cluster.kind_cluster.default will be created
resource "kind_cluster" "default" {
client_certificate     = (known after apply)
client_key             = (known after apply)
cluster_ca_certificate = (known after apply)
endpoint               = (known after apply)
id                     = (known after apply)
kubeconfig             = (known after apply)
kubeconfig_path        = (known after apply)
name                   = "testing"
node_image             = (known after apply)
wait_for_ready         = true
  kind_config {
      api_version = "kind.x-k8s.io/v1alpha4"
      kind        = "Cluster"

      networking {
          disable_default_cni = false
        }

      node {
          role = "control-plane"
        }
    }
}


using:
- terraform version: 0.13.4
- provider version: 0.0.5

find the relevant excerpt of the crash log below:
> ...
2020-10-03T20:00:44.942-0400 [DEBUG] plugin.terraform-provider-kind: 2020/10/03 20:00:44 Creating local Kubernetes cluster...
2020-10-03T20:00:44.945-0400 [DEBUG] plugin.terraform-provider-kind: panic: interface conversion: interface {} is int, not int32
2020-10-03T20:00:44.945-0400 [DEBUG] plugin.terraform-provider-kind: 
2020-10-03T20:00:44.945-0400 [DEBUG] plugin.terraform-provider-kind: goroutine 40 [running]:
2020-10-03T20:00:44.945-0400 [DEBUG] plugin.terraform-provider-kind: github.com/kyma-incubator/terraform-provider-kind/kind.flattenKindConfigNetworking(0xc0003ed920, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
2020-10-03T20:00:44.945-0400 [DEBUG] plugin.terraform-provider-kind:    github.com/kyma-incubator/terraform-provider-kind/kind/structure_kind_config.go:88 +0x561
2020-10-03T20:00:44.945-0400 [DEBUG] plugin.terraform-provider-kind: github.com/kyma-incubator/terraform-provider-kind/kind.flattenKindConfig(0xc0003ec990, 0x1359dad)
2020-10-03T20:00:44.945-0400 [DEBUG] plugin.terraform-provider-kind:    github.com/kyma-incubator/terraform-provider-kind/kind/structure_kind_config.go:27 +0x337
2020-10-03T20:00:44.945-0400 [DEBUG] plugin.terraform-provider-kind: github.com/kyma-incubator/terraform-provider-kind/kind.resourceKindClusterCreate(0xc0003f1650, 0x0, 0x0, 0x2, 0x1fa6880)
2020-10-03T20:00:44.945-0400 [DEBUG] plugin.terraform-provider-kind:    github.com/kyma-incubator/terraform-provider-kind/kind/resource_cluster.go:105 +0x7d6
2020-10-03T20:00:44.945-0400 [DEBUG] plugin.terraform-provider-kind: github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*Resource).Apply(0xc000196900, 0xc0000b3590, 0xc000613c60, 0x0, 0x0, 0x11b7701, 0xc0004f0808, 0xc00028a060)
2020-10-03T20:00:44.945-0400 [DEBUG] plugin.terraform-provider-kind:    github.com/hashicorp/terraform-plugin-sdk@v1.15.0/helper/schema/resource.go:310 +0x365
2020-10-03T20:00:44.945-0400 [DEBUG] plugin.terraform-provider-kind: github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*Provider).Apply(0xc000188e00, 0xc000679a10, 0xc0000b3590, 0xc000613c60, 0xc000281948, 0xc000207108, 0x11b9b00)
2020-10-03T20:00:44.945-0400 [DEBUG] plugin.terraform-provider-kind:    github.com/hashicorp/terraform-plugin-sdk@v1.15.0/helper/schema/provider.go:294 +0x99
2020-10-03T20:00:44.945-0400 [DEBUG] plugin.terraform-provider-kind: github.com/hashicorp/terraform-plugin-sdk/internal/helper/plugin.(*GRPCProviderServer).ApplyResourceChange(0xc000206188, 0x1665000, 0xc000245680, 0xc0003f1030, 0xc000206188, 0xc000245680, 0xc00089cb78)
2020-10-03T20:00:44.945-0400 [DEBUG] plugin.terraform-provider-kind:    github.com/hashicorp/terraform-plugin-sdk@v1.15.0/internal/helper/plugin/grpc_provider.go:885 +0x8b4
2020-10-03T20:00:44.945-0400 [DEBUG] plugin.terraform-provider-kind: github.com/hashicorp/terraform-plugin-sdk/internal/tfplugin5._Provider_ApplyResourceChange_Handler(0x12fef80, 0xc000206188, 0x1665000, 0xc000245680, 0xc000701a40, 0x0, 0x1665000, 0xc000245680, 0xc000251000, 0xddd)
2020-10-03T20:00:44.945-0400 [DEBUG] plugin.terraform-provider-kind:    github.com/hashicorp/terraform-plugin-sdk@v1.15.0/internal/tfplugin5/tfplugin5.pb.go:3305 +0x217
2020-10-03T20:00:44.945-0400 [DEBUG] plugin.terraform-provider-kind: google.golang.org/grpc.(*Server).processUnaryRPC(0xc000683500, 0x1672b40, 0xc00009b200, 0xc000282300, 0xc0005f0960, 0x1f69920, 0x0, 0x0, 0x0)
2020-10-03T20:00:44.945-0400 [DEBUG] plugin.terraform-provider-kind:    google.golang.org/grpc@v1.27.1/server.go:1024 +0x501
2020-10-03T20:00:44.945-0400 [DEBUG] plugin.terraform-provider-kind: google.golang.org/grpc.(*Server).handleStream(0xc000683500, 0x1672b40, 0xc00009b200, 0xc000282300, 0x0)
2020-10-03T20:00:44.945-0400 [DEBUG] plugin.terraform-provider-kind:    google.golang.org/grpc@v1.27.1/server.go:1313 +0xd3d
2020-10-03T20:00:44.945-0400 [DEBUG] plugin.terraform-provider-kind: google.golang.org/grpc.(*Server).serveStreams.func1.1(0xc000516180, 0xc000683500, 0x1672b40, 0xc00009b200, 0xc000282300)
2020-10-03T20:00:44.945-0400 [DEBUG] plugin.terraform-provider-kind:    google.golang.org/grpc@v1.27.1/server.go:722 +0xa1
2020-10-03T20:00:44.945-0400 [DEBUG] plugin.terraform-provider-kind: created by google.golang.org/grpc.(*Server).serveStreams.func1
2020-10-03T20:00:44.945-0400 [DEBUG] plugin.terraform-provider-kind:    google.golang.org/grpc@v1.27.1/server.go:720 +0xa1
2020-10-03T20:00:44.946-0400 [WARN]  plugin.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = transport is closing"
2020/10/03 20:00:44 [DEBUG] module.local_kind_cluster.kind_cluster.default: apply errored, but we're indicating that via the Error pointer rather than returning it: rpc error: code = Unavailable desc = transport is closing
2020/10/03 20:00:44 [TRACE] eval: *terraform.EvalMaybeTainted
2020/10/03 20:00:44 [TRACE] EvalMaybeTainted: module.local_kind_cluster.kind_cluster.default encountered an error during creation, so it is now marked as tainted
2020/10/03 20:00:44 [TRACE] eval: *terraform.EvalWriteState
2020/10/03 20:00:44 [TRACE] states.SyncState: pruning module.local_kind_cluster because it is empty
2020/10/03 20:00:44 [TRACE] EvalWriteState: removing state object for module.local_kind_cluster.kind_cluster.default
2020/10/03 20:00:44 [TRACE] eval: *terraform.EvalApplyProvisioners
2020/10/03 20:00:44 [TRACE] EvalApplyProvisioners: kind_cluster.default has no state, so skipping provisioners
2020/10/03 20:00:44 [TRACE] eval: *terraform.EvalMaybeTainted
2020/10/03 20:00:44 [TRACE] EvalMaybeTainted: module.local_kind_cluster.kind_cluster.default encountered an error during creation, so it is now marked as tainted
2020/10/03 20:00:44 [TRACE] eval: *terraform.EvalWriteState
2020/10/03 20:00:44 [TRACE] states.SyncState: pruning module.local_kind_cluster because it is empty
2020/10/03 20:00:44 [TRACE] EvalWriteState: removing state object for module.local_kind_cluster.kind_cluster.default
2020/10/03 20:00:44 [TRACE] eval: *terraform.EvalIf
2020/10/03 20:00:44 [TRACE] eval: *terraform.EvalIf
2020/10/03 20:00:44 [TRACE] eval: *terraform.EvalWriteDiff
2020/10/03 20:00:44 [TRACE] eval: *terraform.EvalApplyPost
2020/10/03 20:00:44 [ERROR] eval: *terraform.EvalApplyPost, err: rpc error: code = Unavailable desc = transport is closing
2020/10/03 20:00:44 [ERROR] eval: *terraform.EvalSequence, err: rpc error: code = Unavailable desc = transport is closing
...
tehcyx commented 4 years ago

Hey, thanks for the report. I'll take a look at this.