eddycharly / terraform-provider-kops

Brings kOps into terraform in a fully managed way
Apache License 2.0
85 stars 20 forks source link

Nil pointer dereference in validateAdditionalPolicy #370

Closed argoyle closed 3 years ago

argoyle commented 3 years ago

Just tried to retrofit my kOps cluster into Terraform and got this during apply:

Stack trace from the terraform-provider-kops_v1.21.0 plugin:

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

goroutine 25 [running]:
k8s.io/kops/pkg/apis/kops/validation.validateAdditionalPolicy(0xc0007aa714, 0x6, 0xc0007963c0, 0xe9, 0xc000d79470, 0x0, 0xc000d79470, 0x4)
    k8s.io/kops@v1.21.1/pkg/apis/kops/validation/validation.go:890 +0x37a
k8s.io/kops/pkg/apis/kops/validation.validateClusterSpec(0xc0005dda18, 0xc0005dd900, 0xc000d78e70, 0x0, 0x0, 0xc000d78e70)
    k8s.io/kops@v1.21.1/pkg/apis/kops/validation/validation.go:179 +0x3cd9
k8s.io/kops/pkg/apis/kops/validation.newValidateCluster(0xc0005dd900, 0x0, 0x0, 0x0)
    k8s.io/kops@v1.21.1/pkg/apis/kops/validation/validation.go:63 +0x25b
k8s.io/kops/pkg/apis/kops/validation.ValidateCluster(0xc0005dd900, 0xc000510a00, 0x64d95e0, 0xc000d619f0, 0x0)
    k8s.io/kops@v1.21.1/pkg/apis/kops/validation/legacy.go:357 +0x1305
k8s.io/kops/pkg/apis/kops/validation.ValidateClusterUpdate(0xc0005dd900, 0x0, 0xc000510a00, 0x0, 0x0, 0x0)
    k8s.io/kops@v1.21.1/pkg/apis/kops/validation/cluster.go:29 +0x48
k8s.io/kops/pkg/client/simple/vfsclientset.(*ClusterVFS).Update(0xc000fceb58, 0xc0005dd900, 0x0, 0x656ea08, 0xc001034320, 0x64db778)
    k8s.io/kops@v1.21.1/pkg/client/simple/vfsclientset/cluster.go:137 +0x211
k8s.io/kops/pkg/client/simple/vfsclientset.(*VFSClientset).UpdateCluster(0xc00104e590, 0x651aa70, 0xc0000580e8, 0xc0005dd900, 0x0, 0x0, 0xc0001716e0, 0x0)
    k8s.io/kops@v1.21.1/pkg/client/simple/vfsclientset/clientset.go:53 +0xf2
github.com/eddycharly/terraform-provider-kops/pkg/api/resources.UpdateCluster(0xc000650b70, 0xe, 0xc0007960f0, 0xe1, 0xc000e29400, 0xc000650200, 0x6, 0xc000e29310, 0x1, 0x1, ...)
    github.com/eddycharly/terraform-provider-kops/pkg/api/resources/Cluster.go:120 +0x162
github.com/eddycharly/terraform-provider-kops/pkg/resources.ClusterUpdate(0x651aaa8, 0xc000171440, 0xc0008b1400, 0x4d3dcc0, 0xc00104e5a0, 0xc000cac5e0, 0x191dd2a, 0xc000c959a0)
    github.com/eddycharly/terraform-provider-kops/pkg/resources/Cluster.go:43 +0x12f
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).update(0xc000980540, 0x651aa38, 0xc0008c6200, 0xc0008b1400, 0x4d3dcc0, 0xc00104e5a0, 0x0, 0x0, 0x0)
    github.com/hashicorp/terraform-plugin-sdk/v2@v2.7.1/helper/schema/resource.go:364 +0x17f
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0xc000980540, 0x651aa38, 0xc0008c6200, 0xc0011e02a0, 0xc000c959a0, 0x4d3dcc0, 0xc00104e5a0, 0x0, 0x0, 0x0, ...)
    github.com/hashicorp/terraform-plugin-sdk/v2@v2.7.1/helper/schema/resource.go:464 +0x390
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0xc000a32768, 0x651aa38, 0xc0008c6200, 0xc00017a370, 0xc0008c6200, 0x5919960, 0xc000b32200)
    github.com/hashicorp/terraform-plugin-sdk/v2@v2.7.1/helper/schema/grpc_provider.go:955 +0x8ef
github.com/hashicorp/terraform-plugin-go/tfprotov5/server.(*server).ApplyResourceChange(0xc001238d20, 0x651aae0, 0xc0008c6200, 0xc0011e0070, 0xc001238d20, 0xc000b32210, 0xc000e56ba0)
    github.com/hashicorp/terraform-plugin-go@v0.3.0/tfprotov5/server/server.go:332 +0xb5
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler(0x5919960, 0xc001238d20, 0x651aae0, 0xc000b32210, 0xc00092e120, 0x0, 0x651aae0, 0xc000b32210, 0xc000d80000, 0x58fd)
    github.com/hashicorp/terraform-plugin-go@v0.3.0/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:380 +0x214
google.golang.org/grpc.(*Server).processUnaryRPC(0xc000036700, 0x6562758, 0xc0005c3b00, 0xc001070000, 0xc001080510, 0x89ba540, 0x0, 0x0, 0x0)
    google.golang.org/grpc@v1.37.0/server.go:1217 +0x52b
google.golang.org/grpc.(*Server).handleStream(0xc000036700, 0x6562758, 0xc0005c3b00, 0xc001070000, 0x0)
    google.golang.org/grpc@v1.37.0/server.go:1540 +0xd0c
google.golang.org/grpc.(*Server).serveStreams.func1.2(0xc0007de2f0, 0xc000036700, 0x6562758, 0xc0005c3b00, 0xc001070000)
    google.golang.org/grpc@v1.37.0/server.go:878 +0xab
created by google.golang.org/grpc.(*Server).serveStreams.func1
    google.golang.org/grpc@v1.37.0/server.go:876 +0x1fd

Error: The terraform-provider-kops_v1.21.0 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.
argoyle commented 3 years ago

Baah, ignore me. The problem was on my side. I actually passed a null-value into the policies. 🤦🏻‍♂️

eddycharly commented 3 years ago

Ok, thanks for letting me know :)