pulumi-kubernetes
pulumi-kubernetes copied to clipboard
CustomResource with input kind
Problem description
When creating a k8s.apiextensions.CustomResource with a kind argument that is an input instead of a string pulumi crashes.
Errors & Logs
panic: fatal: An assertion has failed: Module member token '{v}suffix`
See https://pulumi.io/help/outputs for more details.
This function may throw in a future version of @pulumi/pulumi.' missing module member delimiter
goroutine 33 [running]:
github.com/pulumi/pulumi/sdk/v2/go/common/util/contract.failfast(...)
/home/travis/gopath/pkg/mod/github.com/pulumi/pulumi/sdk/[email protected]/go/common/util/contract/failfast.go:23
github.com/pulumi/pulumi/sdk/v2/go/common/util/contract.Assertf(0xc001460200, 0x19b8f14, 0x38, 0xc000b3d2e8, 0x1, 0x1)
/home/travis/gopath/pkg/mod/github.com/pulumi/pulumi/sdk/[email protected]/go/common/util/contract/assert.go:33 +0x197
github.com/pulumi/pulumi/sdk/v2/go/common/tokens.ModuleMember.Module(0xc0014602e5, 0x7f, 0xc0014602e5, 0x7f)
/home/travis/gopath/pkg/mod/github.com/pulumi/pulumi/sdk/[email protected]/go/common/tokens/tokens.go:192 +0xd6
github.com/pulumi/pulumi/sdk/v2/go/common/tokens.ModuleMember.Package(0xc0014602e5, 0x7f, 0x1961adf, 0x1)
/home/travis/gopath/pkg/mod/github.com/pulumi/pulumi/sdk/[email protected]/go/common/tokens/tokens.go:187 +0x35
github.com/pulumi/pulumi/sdk/v2/go/common/tokens.Type.Package(0xc0014602e5, 0x7f, 0xc0014602e5, 0x7f)
/home/travis/gopath/pkg/mod/github.com/pulumi/pulumi/sdk/[email protected]/go/common/tokens/tokens.go:227 +0x82
github.com/pulumi/pulumi-kubernetes/provider/v2/pkg/provider.(*kubeProvider).gvkFromURN(0xc00016c000, 0xc0014601c0, 0x1b4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc000b3d4e0, ...)
/home/travis/gopath/src/github.com/pulumi/pulumi-kubernetes/provider/pkg/provider/provider.go:1933 +0x80
github.com/pulumi/pulumi-kubernetes/provider/v2/pkg/provider.(*kubeProvider).Read(0xc00016c000, 0x1bf9860, 0xc000cf34d0, 0xc0015f7040, 0xc00016c000, 0x1753201, 0xc000ad54c0)
/home/travis/gopath/src/github.com/pulumi/pulumi-kubernetes/provider/pkg/provider/provider.go:1477 +0x134c
github.com/pulumi/pulumi/sdk/v2/proto/go._ResourceProvider_Read_Handler.func1(0x1bf9860, 0xc000cf34d0, 0x188dc80, 0xc0015f7040, 0x18b0bc0, 0x28bea50, 0x1bf9860, 0xc000cf34d0)
/home/travis/gopath/pkg/mod/github.com/pulumi/pulumi/sdk/[email protected]/proto/go/provider.pb.go:1902 +0x86
github.com/grpc-ecosystem/grpc-opentracing/go/otgrpc.OpenTracingServerInterceptor.func1(0x1bf9860, 0xc000cf3440, 0x188dc80, 0xc0015f7040, 0xc001552a40, 0xc001552b00, 0x0, 0x0, 0x1bb5760, 0xc000292270)
/home/travis/gopath/pkg/mod/github.com/grpc-ecosystem/[email protected]/go/otgrpc/server.go:57 +0x2f9
github.com/pulumi/pulumi/sdk/v2/proto/go._ResourceProvider_Read_Handler(0x18f5b60, 0xc00016c000, 0x1bf9860, 0xc000cf3440, 0xc000ba27e0, 0xc00000e100, 0x1bf9860, 0xc000cf3440, 0xc0015341e0, 0x1d2)
/home/travis/gopath/pkg/mod/github.com/pulumi/pulumi/sdk/[email protected]/proto/go/provider.pb.go:1904 +0x14b
google.golang.org/grpc.(*Server).processUnaryRPC(0xc000148000, 0x1c18080, 0xc0004bc300, 0xc0001ca200, 0xc0005341b0, 0x2889de0, 0x0, 0x0, 0x0)
/home/travis/gopath/pkg/mod/google.golang.org/[email protected]/server.go:1082 +0x4fd
google.golang.org/grpc.(*Server).handleStream(0xc000148000, 0x1c18080, 0xc0004bc300, 0xc0001ca200, 0x0)
/home/travis/gopath/pkg/mod/google.golang.org/[email protected]/server.go:1405 +0xd23
google.golang.org/grpc.(*Server).serveStreams.func1.1(0xc00057a070, 0xc000148000, 0x1c18080, 0xc0004bc300, 0xc0001ca200)
/home/travis/gopath/pkg/mod/google.golang.org/[email protected]/server.go:746 +0xbb
created by google.golang.org/grpc.(*Server).serveStreams.func1
/home/travis/gopath/pkg/mod/google.golang.org/[email protected]/server.go:744 +0xa1
Affected product version(s)
$ pulumi version
v2.1.0
$ pulumi plugin ls
NAME KIND VERSION SIZE INSTALLED LAST USED
kubernetes resource 2.0.0 52 MB n/a 2 hours ago
Reproducing the issue
import * as pulumi from "@pulumi/pulumi"
import * as k8s from "@pulumi/kubernetes"
new k8s.apiextensions.CustomResource("my-custom-resource", {
kind: pulumi.output("MyCustomResource"),
apiVersion: "my-custom-resource/v1",
})
Suggestions for a fix
Looks like the offending code is this
https://github.com/pulumi/pulumi-kubernetes/blob/915998ac39d885684ca90b428a42bba38f0ad7d9/sdk/nodejs/apiextensions/CustomResource.ts#L151
Here kind is expanded to an error message which is obviously an invalid module suffix.
Looks like the apiVersion and kind were modeled as inputs across all the SDKs, and all suffer from a variation of the problem. Changing the API seems like a last resort here, and so I would advocate for raising an error when the supplied value is not an immediate known value.
One possibility may be to use UnsafeAwaitOutput to wait for the kind to resolve, then throw if the value is unknown. I'm unsure whether that's practical across all the SDKs.
It is proposed that we do a breaking API change for NodeJS SDK, such that the kind and apiversion properties become eager properties (e.g. string vs Input<string>). Assumedly we'd change the Pulumi schema and mark those properties as plain (ref). It is assumed that no program will break because a non-eager value simply didn't work.
This issue has been addressed in PR #3079 and shipped in release v4.15.0.