Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid label causes panic in Python SDK #552

Closed
lblackstone opened this issue May 1, 2019 · 1 comment · Fixed by #655
Closed

Invalid label causes panic in Python SDK #552

lblackstone opened this issue May 1, 2019 · 1 comment · Fixed by #655
Assignees
Labels
area/sdk Related to the Kubernetes SDKs (nodejs, Python, etc.) kind/bug Some behavior is incorrect or out of spec language/python p1 A bug severe enough to be the next item assigned to an engineer
Milestone

Comments

@lblackstone
Copy link
Member

import pulumi
from pulumi_kubernetes.core.v1 import Pod

pod = Pod(
    "foo",
    metadata={"labels": "foo"},
    spec={"containers": [{"name": "nginx", "image": "nginx"}]}
)

causes the following panic:

    panic: interface conversion: interface {} is string, not map[string]interface {}
    goroutine 133 [running]:
    github.com/pulumi/pulumi-kubernetes/pkg/metadata.SetLabel(...)
    	/Users/levi/go/src/github.com/pulumi/pulumi-kubernetes/pkg/metadata/labels.go:31
    github.com/pulumi/pulumi-kubernetes/pkg/metadata.SetManagedByLabel(...)
    	/Users/levi/go/src/github.com/pulumi/pulumi-kubernetes/pkg/metadata/labels.go:40
    github.com/pulumi/pulumi-kubernetes/pkg/provider.(*kubeProvider).Check(0xc0004dc600, 0x257c880, 0xc00137e3c0, 0xc001380000, 0xc0004dc600, 0x213bd01, 0xc001380080)
    	/Users/levi/go/src/github.com/pulumi/pulumi-kubernetes/pkg/provider/provider.go:273 +0x16b0
    github.com/pulumi/pulumi-kubernetes/vendor/github.com/pulumi/pulumi/sdk/proto/go._ResourceProvider_Check_Handler.func1(0x257c880, 0xc00137e3c0, 0x226f200, 0xc001380000, 0x228e6a0, 0x340dcf8, 0x257c880, 0xc00137e3c0)
    	/Users/levi/go/src/github.com/pulumi/pulumi-kubernetes/vendor/github.com/pulumi/pulumi/sdk/proto/go/provider.pb.go:1303 +0x86
    github.com/pulumi/pulumi-kubernetes/vendor/github.com/grpc-ecosystem/grpc-opentracing/go/otgrpc.OpenTracingServerInterceptor.func1(0x257c880, 0xc00137e000, 0x226f200, 0xc001380000, 0xc001378020, 0xc001378040, 0x0, 0x0, 0x253dc20, 0xc0004e5d60)
    	/Users/levi/go/src/github.com/pulumi/pulumi-kubernetes/vendor/github.com/grpc-ecosystem/grpc-opentracing/go/otgrpc/server.go:61 +0x360
    github.com/pulumi/pulumi-kubernetes/vendor/github.com/pulumi/pulumi/sdk/proto/go._ResourceProvider_Check_Handler(0x22900e0, 0xc0004dc600, 0x257c880, 0xc00137e000, 0xc00137c000, 0xc00044d180, 0x257c880, 0xc00137e000, 0xc00137a000, 0xc8)
    	/Users/levi/go/src/github.com/pulumi/pulumi-kubernetes/vendor/github.com/pulumi/pulumi/sdk/proto/go/provider.pb.go:1305 +0x158
    github.com/pulumi/pulumi-kubernetes/vendor/google.golang.org/grpc.(*Server).processUnaryRPC(0xc0004cf500, 0x2597b40, 0xc0004b2300, 0xc000012100, 0xc000137f50, 0x33dec60, 0x0, 0x0, 0x0)
    	/Users/levi/go/src/github.com/pulumi/pulumi-kubernetes/vendor/google.golang.org/grpc/server.go:972 +0x470
    github.com/pulumi/pulumi-kubernetes/vendor/google.golang.org/grpc.(*Server).handleStream(0xc0004cf500, 0x2597b40, 0xc0004b2300, 0xc000012100, 0x0)
    	/Users/levi/go/src/github.com/pulumi/pulumi-kubernetes/vendor/google.golang.org/grpc/server.go:1252 +0xda6
    github.com/pulumi/pulumi-kubernetes/vendor/google.golang.org/grpc.(*Server).serveStreams.func1.1(0xc0000ee090, 0xc0004cf500, 0x2597b40, 0xc0004b2300, 0xc000012100)
    	/Users/levi/go/src/github.com/pulumi/pulumi-kubernetes/vendor/google.golang.org/grpc/server.go:691 +0x9f
    created by github.com/pulumi/pulumi-kubernetes/vendor/google.golang.org/grpc.(*Server).serveStreams.func1
    	/Users/levi/go/src/github.com/pulumi/pulumi-kubernetes/vendor/google.golang.org/grpc/server.go:689 +0xa1

Labels should be a dict rather than a string (e.g. "labels": {"foo": "true"}, not "labels": "foo"), but this error should be caught before it causes a panic in the provider.

@lblackstone lblackstone added kind/bug Some behavior is incorrect or out of spec language/python area/sdk Related to the Kubernetes SDKs (nodejs, Python, etc.) labels May 1, 2019
@lblackstone lblackstone self-assigned this May 1, 2019
hausdorff added a commit that referenced this issue Jul 25, 2019
hausdorff added a commit that referenced this issue Jul 25, 2019
@hausdorff
Copy link
Contributor

Not 100% we're on the same page when we say "before it causes a panic with the provider", but SetLabels should return an error if it can't set labels because labels are mistyped. We should not try to inject typing logic into the SDK.

hausdorff added a commit that referenced this issue Jul 25, 2019
hausdorff added a commit that referenced this issue Jul 25, 2019
@lukehoban lukehoban added this to the 0.25 milestone Jul 25, 2019
@hausdorff hausdorff assigned hausdorff and unassigned lblackstone Jul 25, 2019
hausdorff added a commit that referenced this issue Jul 25, 2019
hausdorff added a commit that referenced this issue Jul 25, 2019
@infin8x infin8x added the p1 A bug severe enough to be the next item assigned to an engineer label Jul 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/sdk Related to the Kubernetes SDKs (nodejs, Python, etc.) kind/bug Some behavior is incorrect or out of spec language/python p1 A bug severe enough to be the next item assigned to an engineer
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants