hashicorp / terraform-provider-kubernetes

Terraform Kubernetes provider
https://www.terraform.io/docs/providers/kubernetes/
Mozilla Public License 2.0
1.56k stars 966 forks source link

(*GRPCProvider).ApplyResourceChange/.PlanResourceChange call Error #2074

Closed slavayssiere-stacklabs closed 1 year ago

slavayssiere-stacklabs commented 1 year ago

Terraform Version, Provider Version and Kubernetes Version

Terraform version:
Kubernetes provider version: [v2.19.0](https://github.com/hashicorp/terraform-provider-kubernetes/releases/tag/v2.19.0)
Kubernetes version: Terraform v1.4.5 on darwin_arm64

Affected Resource(s)

Debug Output

│ Error: Plugin did not respond │ │ with module.mod-postapply.kubernetes_job_v1.admin-grafana, │ on ../mod-postapply/prometheus-operator.tf line 248, in resource "kubernetes_job_v1" "admin-grafana": │ 248: resource "kubernetes_job_v1" "admin-grafana" { │ │ The plugin encountered an error, and failed to respond to the plugin.(GRPCProvider).ApplyResourceChange call. The plugin logs may contain more details. ╵ ╷ │ Error: Plugin did not respond │ │ with module.mod-postapply.kubernetes_manifest.ingress-dashboard-private, │ on ../mod-postapply/traefik-ic.tf line 237, in resource "kubernetes_manifest" "ingress-dashboard-private": │ 237: resource "kubernetes_manifest" "ingress-dashboard-private" { │ │ The plugin encountered an error, and failed to respond to the plugin.(GRPCProvider).PlanResourceChange call. The plugin logs may contain more details. ╵ ╷ │ Error: Request cancelled │ │ with module.mod-postapply.kubernetes_manifest.ingress-dashboard-public, │ on ../mod-postapply/traefik-ic.tf line 287, in resource "kubernetes_manifest" "ingress-dashboard-public": │ 287: resource "kubernetes_manifest" "ingress-dashboard-public" { │ │ The plugin.(*GRPCProvider).PlanResourceChange request was cancelled.

Panic Output

Stack trace from the terraform-provider-kubernetes_v2.19.0_x5 plugin:

panic: interface conversion: interface {} is nil, not map[string]interface {}

goroutine 177 [running]: github.com/hashicorp/terraform-provider-kubernetes/kubernetes.expandLocalObjectReferenceArray(...) github.com/hashicorp/terraform-provider-kubernetes/kubernetes/structures.go:655 github.com/hashicorp/terraform-provider-kubernetes/kubernetes.expandPodSpec({0x140011e5eb0, 0x1, 0x1019c0ea6?}) github.com/hashicorp/terraform-provider-kubernetes/kubernetes/structures_pod.go:749 +0x136c github.com/hashicorp/terraform-provider-kubernetes/kubernetes.expandPodTemplate({0x140011e5e30, 0x1, 0x1019c6760?}) github.com/hashicorp/terraform-provider-kubernetes/kubernetes/structuresdeployment.go:119 +0x18c github.com/hashicorp/terraform-provider-kubernetes/kubernetes.expandJobSpec({, , }) github.com/hashicorp/terraform-provider-kubernetes/kubernetes/structure_job.go:105 +0x3b4 github.com/hashicorp/terraform-provider-kubernetes/kubernetes.resourceKubernetesJobCreate({0x1021c7648, 0x140006de9c0}, 0x14001402a80, {0x1020ce560?, 0x1400149a460}) github.com/hashicorp/terraform-provider-kubernetes/kubernetes/resource_kubernetes_job.go:78 +0x174 github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(Resource).create(0x14000f55260, {0x1021c7680, 0x14000b44fc0}, 0xd?, {0x1020ce560, 0x1400149a460}) github.com/hashicorp/terraform-plugin-sdk/v2@v2.24.1/helper/schema/resource.go:707 +0xe8 github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(Resource).Apply(0x14000f55260, {0x1021c7680, 0x14000b44fc0}, 0x14000f8cb60, 0x14000546b80, {0x1020ce560, 0x1400149a460}) github.com/hashicorp/terraform-plugin-sdk/v2@v2.24.1/helper/schema/resource.go:837 +0x86c github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(GRPCProviderServer).ApplyResourceChange(0x1400000ef60, {0x1021c7680?, 0x14000b44e40?}, 0x14000e8aa50) github.com/hashicorp/terraform-plugin-sdk/v2@v2.24.1/helper/schema/grpc_provider.go:1021 +0xb70 github.com/hashicorp/terraform-plugin-mux/tf5muxserver.muxServer.ApplyResourceChange({0x14000b17b60, 0x14000b17bf0, {0x140012eaa00, 0x2, 0x2}, 0x14000b17bc0, 0x14000c16e80, 0x140012b2990, 0x14000b17c50}, {0x1021c7680?, ...}, ...) github.com/hashicorp/terraform-plugin-mux@v0.7.0/tf5muxserver/mux_server_ApplyResourceChange.go:27 +0x108 github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(server).ApplyResourceChange(0x140006b1900, {0x1021c7680?, 0x14000b441e0?}, 0x14000cf2150) github.com/hashicorp/terraform-plugin-go@v0.14.2/tfprotov5/tf5server/server.go:818 +0x3b8 github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0x1020c78c0?, 0x140006b1900}, {0x1021c7680, 0x14000b441e0}, 0x14000cf20e0, 0x0) github.com/hashicorp/terraform-plugin-go@v0.14.2/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:385 +0x170 google.golang.org/grpc.(Server).processUnaryRPC(0x14000eba3c0, {0x1021ce0a0, 0x14000fec680}, 0x14000616000, 0x1400139eba0, 0x1030a9da0, 0x0) google.golang.org/grpc@v1.51.0/server.go:1340 +0xb7c google.golang.org/grpc.(Server).handleStream(0x14000eba3c0, {0x1021ce0a0, 0x14000fec680}, 0x14000616000, 0x0) google.golang.org/grpc@v1.51.0/server.go:1713 +0x82c google.golang.org/grpc.(Server).serveStreams.func1.2() google.golang.org/grpc@v1.51.0/server.go:965 +0x84 created by google.golang.org/grpc.(Server).serveStreams.func1 google.golang.org/grpc@v1.51.0/server.go:963 +0x290

Error: The terraform-provider-kubernetes_v2.19.0_x5 plugin crashed!

This is always indicative of a bug within the plugin. It would be immensely helpful if you could report the crash with the plugin's maintainers so that it can be fixed. The output above should help diagnose the issue.

Steps to Reproduce

  1. terraform apply

Expected Behavior

No Terraform panic

Actual Behavior

Terraform panic

Community Note

slavayssiere-stacklabs commented 1 year ago

It was an crash due to a image_pull_secrets.name with empty string. Solve using :

dynamic "image_pull_secrets" {
  for_each = toset(length(var.image_pull_secrets) == 0 ? [] : [var.image_pull_secrets])
    content {
      name = image_pull_secrets.key
    } 
}