banzaicloud / terraform-provider-k8s

Kubernetes Terraform provider with support for raw manifests
https://registry.terraform.io/providers/banzaicloud/k8s
MIT License
135 stars 30 forks source link

The terraform-provider-k8s_v0.9.1 plugin crashed #81

Open gurpreetkandola opened 3 years ago

gurpreetkandola commented 3 years ago

Describe the bug The terraform-provider-k8s_v0.9.1 plugin crashed

╷
│ Error: Plugin did not respond
│ 
│ The plugin encountered an error, and failed to respond to the plugin.(*GRPCProvider).ConfigureProvider call. The plugin logs may contain more details.
╵

Stack trace from the terraform-provider-k8s_v0.9.1 plugin:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x198 pc=0x23801eb]

goroutine 49 [running]:
github.com/banzaicloud/terraform-provider-k8s/k8s.providerConfigure(0xc00059a2a0, 0xc0000c39e0, 0x6, 0xc00059a2a0, 0x0, 0x0, 0x0)
        /Users/nandork/go/src/github.com/banzaicloud/terraform-provider-k8s/k8s/provider.go:183 +0x16b
github.com/banzaicloud/terraform-provider-k8s/k8s.Provider.func1(0xc00059a2a0, 0x0, 0xc000b28440, 0xc00059a2a0, 0x0)
        /Users/nandork/go/src/github.com/banzaicloud/terraform-provider-k8s/k8s/provider.go:149 +0x58
github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*Provider).Configure(0xc000194b80, 0xc00058cde0, 0x24d3960, 0xc00058cb70)
        /Users/nandork/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk@v1.15.0/helper/schema/provider.go:275 +0xfc
github.com/hashicorp/terraform-plugin-sdk/internal/helper/plugin.(*GRPCProviderServer).Configure(0xc0001967a8, 0x2995570, 0xc00053be30, 0xc0005ddd00, 0xc0001967a8, 0xc00053be30, 0xc000b23b80)
        /Users/nandork/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk@v1.15.0/internal/helper/plugin/grpc_provider.go:487 +0x2ee
github.com/hashicorp/terraform-plugin-sdk/internal/tfplugin5._Provider_Configure_Handler(0x265f560, 0xc0001967a8, 0x2995570, 0xc00053be30, 0xc00007f0e0, 0x0, 0x2995570, 0xc00053be30, 0xc000734600, 0x5d5)
        /Users/nandork/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk@v1.15.0/internal/tfplugin5/tfplugin5.pb.go:3251 +0x214
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0006c2600, 0x29a8018, 0xc0006c3080, 0xc000632c00, 0xc0000ba5a0, 0x3462678, 0x0, 0x0, 0x0)
        /Users/nandork/go/pkg/mod/google.golang.org/grpc@v1.27.1/server.go:1024 +0x522
google.golang.org/grpc.(*Server).handleStream(0xc0006c2600, 0x29a8018, 0xc0006c3080, 0xc000632c00, 0x0)
        /Users/nandork/go/pkg/mod/google.golang.org/grpc@v1.27.1/server.go:1313 +0xd2c
google.golang.org/grpc.(*Server).serveStreams.func1.1(0xc0000c21a0, 0xc0006c2600, 0x29a8018, 0xc0006c3080, 0xc000632c00)
        /Users/nandork/go/pkg/mod/google.golang.org/grpc@v1.27.1/server.go:722 +0xab
created by google.golang.org/grpc.(*Server).serveStreams.func1
        /Users/nandork/go/pkg/mod/google.golang.org/grpc@v1.27.1/server.go:720 +0xa5

Error: The terraform-provider-k8s_v0.9.1 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.

make: *** [plan] Error 1

Steps to reproduce the issue: Set k8s provider in terraform:

terraform {
  required_version = "= 0.15.0"
  required_providers {
    k8s = {
      version = ">= 0.8.0"
      source  = "banzaicloud/k8s"
    }
  }
}

And tried to deploy manifest k8s resource

Expected behavior Should apply manifest resource with no error

bozerkins commented 3 years ago

Having the same issue.

bozerkins commented 3 years ago

Currently it looks like the issue occurs from this line https://github.com/banzaicloud/terraform-provider-k8s/blob/master/k8s/provider.go#L290

Not sure why, though

receperdogan commented 3 years ago

hi there, I am getting same error when i changed direct kubernetes endpoint cluster IP to load balance endpoint cluster ip. LB endpoint ip is reaching to k8s master node. But plugin still crashes.

LevinDmytro2 commented 3 years ago

I have the same issue. I'm getting this after I deleted kubeconfig When I ran command aws eks --region us-west-1 update-kubeconfig --name clustername and run again, issue resolved. But in my case I need to run any providers without any kubeconfigs with similar construction: provider "k8s" { host = aws_eks_cluster.example.endpoint cluster_ca_certificate = base64decode(aws_eks_cluster.example.certificate_authority.0.data) exec { api_version = "client.authentication.k8s.io/v1alpha1" args = ["eks", "get-token", "--cluster-name", aws_eks_cluster.example.name] command = "aws" } }

rauny-brandao commented 3 years ago

Having the same issue, rolling back to version: 0.8.2 fixed the problem for me.

Provider config:

provider "k8s" {
  host                   = var.cluster_endpoint
  cluster_ca_certificate = base64decode(var.cluster_certificate_authority_data)
  exec {
    api_version = "client.authentication.k8s.io/v1alpha1"
    args        = ["eks", "get-token", "--cluster-name", var.cluster_name]
    command     = "aws"
  }
}

Another "fix" was running this command: aws eks --region us-west-1 update-kubeconfig --name clustername as mentioned by @LevinDmytro2