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 v1.List panics kubectl #53735

Closed
unixwitch opened this Issue Oct 11, 2017 · 3 comments

Comments

Projects
None yet
6 participants
@unixwitch

unixwitch commented Oct 11, 2017

Is this a BUG REPORT or FEATURE REQUEST?:
/kind bug
/sig cli

What happened:

I accidentally tried to apply an invalid v1.List with kubectl apply:

% cat testlist.json 
{
        "apiVersion": "v1",
        "kind": "List",
        "items": [ [] ]
}

kubectl responded by crashing with a panic:

% kubectl apply -f testlist.json
panic: interface conversion: interface {} is []interface {}, not map[string]interface {}

goroutine 1 [running]:
k8s.io/kubernetes/pkg/kubectl/cmd/util/openapi/validation.getObjectKind(0x14dbba0, 0xc420cffd00, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x40b2d2, 0xc4213fc2fc)
        /go/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/pkg/kubectl/cmd/util/openapi/validation/validation.go:111 +0x539
k8s.io/kubernetes/pkg/kubectl/cmd/util/openapi/validation.(*SchemaValidation).validateList(0xc4209e6260, 0x15a5c80, 0xc4213d33b0, 0x4, 0xc4213fc201, 0x2)
        /go/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/pkg/kubectl/cmd/util/openapi/validation/validation.go:69 +0x14f
k8s.io/kubernetes/pkg/kubectl/cmd/util/openapi/validation.(*SchemaValidation).ValidateBytes(0xc4209e6260, 0xc4213fe480, 0x3a, 0x40, 0xc42064f450, 0x4ed384)
        /go/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/pkg/kubectl/cmd/util/openapi/validation/validation.go:55 +0x134
k8s.io/kubernetes/pkg/kubectl/validation.ConjunctiveSchema.ValidateBytes(0xc42107e8e0, 0x2, 0x2, 0xc4213fe480, 0x3a, 0x40, 0x4ed029, 0xc4213fe480)
        /go/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/pkg/kubectl/validation/schema.go:130 +0x9a
k8s.io/kubernetes/pkg/kubectl/validation.(*ConjunctiveSchema).ValidateBytes(0xc42107e900, 0xc4213fe480, 0x3a, 0x40, 0xc42064f528, 0x443693)
        <autogenerated>:3 +0x7d
k8s.io/kubernetes/pkg/kubectl/resource.ValidateSchema(0xc4213fe480, 0x3a, 0x40, 0x2183000, 0xc42107e900, 0x20, 0xc42064f500)
        /go/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/pkg/kubectl/resource/visitor.go:222 +0x68
k8s.io/kubernetes/pkg/kubectl/resource.(*StreamVisitor).Visit(0xc4213fe3c0, 0xc420cffc20, 0x2189080, 0xc420cffc80)
        /go/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/pkg/kubectl/resource/visitor.go:543 +0x269
k8s.io/kubernetes/pkg/kubectl/resource.(*FileVisitor).Visit(0xc420cffa60, 0xc420cffc20, 0x0, 0x0)
        /go/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/pkg/kubectl/resource/visitor.go:502 +0x181
k8s.io/kubernetes/pkg/kubectl/resource.EagerVisitorList.Visit(0xc4213fc250, 0x1, 0x1, 0xc4213d3350, 0x1, 0xc4213d3350)
        /go/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/pkg/kubectl/resource/visitor.go:211 +0x100
k8s.io/kubernetes/pkg/kubectl/resource.(*EagerVisitorList).Visit(0xc420cffb00, 0xc4213d3350, 0x7f2a1642c960, 0x0)
        <autogenerated>:115 +0x69
k8s.io/kubernetes/pkg/kubectl/resource.FlattenListVisitor.Visit(0x2182d80, 0xc420cffb00, 0xc4213fe380, 0xc4213fe440, 0xc420cffb01, 0xc4213fe440)
        /go/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/pkg/kubectl/resource/visitor.go:417 +0xa3
k8s.io/kubernetes/pkg/kubectl/resource.(*FlattenListVisitor).Visit(0xc420cffb20, 0xc4213fe440, 0x18, 0x18)
        <autogenerated>:130 +0x69
k8s.io/kubernetes/pkg/kubectl/resource.DecoratedVisitor.Visit(0x2182e00, 0xc420cffb20, 0xc420cffb60, 0x3, 0x4, 0xc420cffbe0, 0x1, 0xc420cffbe0)
        /go/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/pkg/kubectl/resource/visitor.go:325 +0xd8
k8s.io/kubernetes/pkg/kubectl/resource.(*DecoratedVisitor).Visit(0xc4213d32c0, 0xc420cffbe0, 0x7f2a1642c960, 0x15d530c)
        <autogenerated>:153 +0x73
k8s.io/kubernetes/pkg/kubectl/resource.ContinueOnErrorVisitor.Visit(0x2182d00, 0xc4213d32c0, 0xc42124f970, 0x7f2a1642c960, 0x0)
        /go/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/pkg/kubectl/resource/visitor.go:352 +0xf1
k8s.io/kubernetes/pkg/kubectl/resource.(*ContinueOnErrorVisitor).Visit(0xc4213fc270, 0xc42124f970, 0x40f3f8, 0xb0)
        <autogenerated>:144 +0x60
k8s.io/kubernetes/pkg/kubectl/resource.(*Result).Visit(0xc4203085b0, 0xc42124f970, 0x0, 0xc4213d3320)
        /go/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/pkg/kubectl/resource/result.go:95 +0x62
k8s.io/kubernetes/pkg/kubectl/cmd.RunApply(0x21abde0, 0xc4203db410, 0xc4201b9d40, 0x2181e40, 0xc42000c018, 0x2181e40, 0xc42000c020, 0xc42014b5e0, 0x176e8e8, 0x4)
        /go/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/pkg/kubectl/cmd/apply.go:351 +0x70c
k8s.io/kubernetes/pkg/kubectl/cmd.NewCmdApply.func1(0xc4201b9d40, 0xc420284fa0, 0x0, 0x2)
        /go/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/pkg/kubectl/cmd/apply.go:113 +0x188
k8s.io/kubernetes/vendor/github.com/spf13/cobra.(*Command).execute(0xc4201b9d40, 0xc420284b00, 0x2, 0x2, 0xc4201b9d40, 0xc420284b00)
        /go/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/vendor/github.com/spf13/cobra/command.go:603 +0x22b
k8s.io/kubernetes/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0xc42022c900, 0x7000105, 0x0, 0xffffffffffffffff)
        /go/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/vendor/github.com/spf13/cobra/command.go:689 +0x339
k8s.io/kubernetes/vendor/github.com/spf13/cobra.(*Command).Execute(0xc42022c900, 0xc4203db410, 0x2181e00)
        /go/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/vendor/github.com/spf13/cobra/command.go:648 +0x2b
k8s.io/kubernetes/cmd/kubectl/app.Run(0x0, 0x0)
        /go/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/cmd/kubectl/app/kubectl.go:39 +0xd5
main.main()
        /go/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/cmd/kubectl/kubectl.go:26 +0x22

What you expected to happen:

An error message to be printed, perhaps of the "invalid List item: []".

How to reproduce it (as minimally and precisely as possible):

See description.

Environment:

  • Kubernetes version (use kubectl version):
Client Version: version.Info{Major:"1", Minor:"8", GitVersion:"v1.8.0", GitCommit:"6e937839ac04a38cac63e6a7a306c5d035fe7b0a", GitTreeState:"clean", BuildDate:"2017-09-28T22:57:57Z", GoVersion:"go1.8.3", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"8", GitVersion:"v1.8.0", GitCommit:"6e937839ac04a38cac63e6a7a306c5d035fe7b0a", GitTreeState:"clean", BuildDate:"2017-09-28T22:46:41Z", GoVersion:"go1.8.3", Compiler:"gc", Platform:"linux/amd64"}
  • Cloud provider or hardware configuration**: GCE
  • OS (e.g. from /etc/os-release): CentOS 7.4 (1708)
  • Kernel (e.g. uname -a): Linux staging-head-2 3.10.0-693.2.2.el7.x86_64 #1 SMP Tue Sep 12 22:26:13 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
  • Install tools: Custom scripts
  • Others:
@tanshanshan

This comment has been minimized.

Show comment
Hide comment
@tanshanshan

tanshanshan Oct 12, 2017

Member

I would try to fix it.

Member

tanshanshan commented Oct 12, 2017

I would try to fix it.

@stewart-yu

This comment has been minimized.

Show comment
Hide comment
@stewart-yu

stewart-yu Oct 12, 2017

Contributor

Can you add --validate=true in command line, then have a try?

Contributor

stewart-yu commented Oct 12, 2017

Can you add --validate=true in command line, then have a try?

@pwittrock

This comment has been minimized.

Show comment
Hide comment
@pwittrock
Member

pwittrock commented Oct 19, 2017

k8s-merge-robot added a commit that referenced this issue Nov 22, 2017

Merge pull request #53765 from tanshanshan/fix-bug1
Automatic merge from submit-queue (batch tested with PRs 54529, 53765). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

fix  #53735, check whether  interface conversion is ok

**What this PR does / why we need it**:

**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #

fix #53735

avoid interface conversion error 

**Special notes for your reviewer**:

**Release note**:

```release-note
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment