should i be worried about a goroutine panic that s...
# kubernetes
b
should i be worried about a goroutine panic that seems to be related to my kubeconfig, but doesn't actually seem to affect the correctness of my program ... ?
Copy code
panic: interface conversion: interface {} is resource.PropertyMap, not string
    goroutine 28 [running]:
    <http://github.com/pulumi/pulumi/pkg/resource.PropertyValue.StringValue(...)|github.com/pulumi/pulumi/pkg/resource.PropertyValue.StringValue(...)>
    	/home/travis/gopath/pkg/mod/github.com/pulumi/pulumi@v1.6.1/pkg/resource/properties.go:359
    <http://github.com/pulumi/pulumi-kubernetes/pkg/provider.parseKubeconfigPropertyValue(0x2386280|github.com/pulumi/pulumi-kubernetes/pkg/provider.parseKubeconfigPropertyValue(0x2386280>, 0xc0001fea50, 0x2475423, 0xa, 0xc0001b2508)
    	/home/travis/gopath/src/github.com/pulumi/pulumi-kubernetes/pkg/provider/util.go:85 +0x169
    <http://github.com/pulumi/pulumi-kubernetes/pkg/provider.(*kubeProvider).DiffConfig(0xc000014000|github.com/pulumi/pulumi-kubernetes/pkg/provider.(*kubeProvider).DiffConfig(0xc000014000>, 0x26e1260, 0xc0001fe9f0, 0xc0001380e0, 0xc000014000, 0x2275301, 0xc00031a0c0)
    	/home/travis/gopath/src/github.com/pulumi/pulumi-kubernetes/pkg/provider/provider.go:278 +0x61b
    <http://github.com/pulumi/pulumi/sdk/proto/go._ResourceProvider_DiffConfig_Handler.func1(0x26e1260|github.com/pulumi/pulumi/sdk/proto/go._ResourceProvider_DiffConfig_Handler.func1(0x26e1260>, 0xc0001fe9f0, 0x23a5e80, 0xc0001380e0, 0x23c0a00, 0x33070c0, 0x26e1260, 0xc0001fe9f0)
    	/home/travis/gopath/pkg/mod/github.com/pulumi/pulumi@v1.6.1/sdk/proto/go/provider.pb.go:1504 +0x86
    <http://github.com/grpc-ecosystem/grpc-opentracing/go/otgrpc.OpenTracingServerInterceptor.func1(0x26e1260|github.com/grpc-ecosystem/grpc-opentracing/go/otgrpc.OpenTracingServerInterceptor.func1(0x26e1260>, 0xc000577200, 0x23a5e80, 0xc0001380e0, 0xc00000cb20, 0xc00000cb40, 0x0, 0x0, 0x26a05e0, 0xc0000cf7b0)
    	/home/travis/gopath/pkg/mod/github.com/grpc-ecosystem/grpc-opentracing@v0.0.0-20171105060200-01f8541d5372/go/otgrpc/server.go:61 +0x36e
    <http://github.com/pulumi/pulumi/sdk/proto/go._ResourceProvider_DiffConfig_Handler(0x2402f60|github.com/pulumi/pulumi/sdk/proto/go._ResourceProvider_DiffConfig_Handler(0x2402f60>, 0xc000014000, 0x26e1260, 0xc000577200, 0xc0000de3c0, 0xc0004d2040, 0x26e1260, 0xc000577200, 0xc000331300, 0x101f)
    	/home/travis/gopath/pkg/mod/github.com/pulumi/pulumi@v1.6.1/sdk/proto/go/provider.pb.go:1506 +0x14b
    <http://google.golang.org/grpc.(*Server).processUnaryRPC(0xc00034e300|google.golang.org/grpc.(*Server).processUnaryRPC(0xc00034e300>, 0x26fdc00, 0xc00045b500, 0xc00015a200, 0xc000436180, 0x32d3258, 0x0, 0x0, 0x0)
    	/home/travis/gopath/pkg/mod/google.golang.org/grpc@v1.21.1/server.go:998 +0x46a
    <http://google.golang.org/grpc.(*Server).handleStream(0xc00034e300|google.golang.org/grpc.(*Server).handleStream(0xc00034e300>, 0x26fdc00, 0xc00045b500, 0xc00015a200, 0x0)
    	/home/travis/gopath/pkg/mod/google.golang.org/grpc@v1.21.1/server.go:1278 +0xd97
    <http://google.golang.org/grpc.(*Server).serveStreams.func1.1(0xc00039bd30|google.golang.org/grpc.(*Server).serveStreams.func1.1(0xc00039bd30>, 0xc00034e300, 0x26fdc00, 0xc00045b500, 0xc00015a200)
    	/home/travis/gopath/pkg/mod/google.golang.org/grpc@v1.21.1/server.go:717 +0xbb
    created by <http://google.golang.org/grpc.(*Server).serveStreams.func1|google.golang.org/grpc.(*Server).serveStreams.func1>
    	/home/travis/gopath/pkg/mod/google.golang.org/grpc@v1.21.1/server.go:715 +0xa1
w
Yeah - definitely a bug that this results in a panic. But it does appears this indicates some potential issue with your Pulumi program. What is the
kubeconfig
property set to in your program (and in your state file)? It is expected to be a string, but it looks like perhaps you are passing an object?
b
i'm passing an object, yes. it's a EKS cluster's
kubeconfig
value, exported from another stack.
interestingly, it all still seems to work ...
export looks like:
Copy code
export const eksKubeconfig = eksCluster.kubeconfig;
w
I believe this is supposed to accept a string, and that in general you need to
JSON.stringify
an object if passed in here. What language are you using? I would have expected a type-error in your language even ahead of being able to reach this. All of the occurences of
kubeconfig:
in pulumi/examples show passing it a string (from various different sources), including this snippet in the
aws-ts-eks
README:
Copy code
const myk8s = new k8s.Provider("myk8s", {
        kubeconfig: cluster.kubeconfig.apply(JSON.stringify),
    });
b
this is all typescript - and yeah, it's weird it's not caught in the type checker.
it looks like that's happy with an
any
or something?
Copy code
const providerKubeconfig = infraStack.requireOutput("eksClusterKubeconfig");
const eksProvider = new k8s.Provider("eks-k8s-provider", {
  kubeconfig: providerKubeconfig
});
there's actually a related feature request i'd love to submit where the kubeconfig builder function is exported from that module
really, we don't want to be using the cluster provider, because it has full admin permissions.
we want a tighter role in our kubeconfig, but today that means patching in the right
args
array to the returned cluster value, which is pretty dang ugly.
w
Ahh - I see, yeah
requireOutput
returns
any
. So unless you cast that explicitly into what you know it actually is - this won't get caught.
there's actually a related feature request i'd love to submit where the kubeconfig builder function is exported from that module
That's a good idea. Mind opening an issue in
pulumi/eks
? I think this has come up before (and there may even already be an issue there?).
b
not at all, it's on my TODO backlog 😉
FWIW the original issue that started this thread did cause pulumi to horribly break the first time the provider changed. like, it panicked even trying to preview, and i had to go in and fix the state file by-hand. 😬
s
I have been struggling with this issue as well. I am consuming an exported
kubeconfig
from another stack and receiving a panic when the config is consumed by the
Provider
method. However, changes are applied to the stack with no other errors.
Copy code
panic: interface conversion: interface {} is resource.PropertyMap, not string
exporting stack:
Copy code
const clusterObj = cluster.create(controlPlaneSg, ngRole);

export const kubeconfig = clusterObj.kubeconfig;
consuming stack:
Copy code
export const clusterStackRef = new pulumi.StackReference(`project/trips/${envName}`);

const clusterKubeconfig = clusterStackRef.requireOutput("kubeconfig");

const provider = new k8s.Provider("provider", { kubeconfig: clusterKubeconfig });
w
You need to pass a string to
k8s.Provider( { kubeconfig: ... })
. Is your exported
kubeconfig
a string or an object? We should at least have a better error here, if not accept either a string or an object.
Added a note at https://github.com/pulumi/pulumi-kubernetes/issues/1032#issuecomment-603907316, and that issue also has more details on the need to JSON.stringify.
s
Thanks @white-balloon-205. I am exporting the
kubeconfig
as an object. I added
JSON.stringify
but I get the same panic, even on preview.
Copy code
const clusterKubeconfig = clusterStackRef.requireOutput("kubeconfig").apply(JSON.stringify);

const provider = new k8s.Provider("provider", { kubeconfig: clusterKubeconfig });
b
if you've ever run the stack with the object kubeconfig, you're now stuck with a bad provider in your statefile. you're going to have to edit it out & replace it with the stringified version (or something similar; that's what i did to unstick myself)
s
Good call @brave-ambulance-98491, manually swapping out the object for the stringified version resolved the panic ✌️
👍🏻 1