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

"kubectl cp" with no arguments causes a panic #65475

Closed
gjcarneiro opened this Issue Jun 26, 2018 · 7 comments

Comments

Projects
None yet
5 participants
@gjcarneiro
Copy link

commented Jun 26, 2018

Is this a BUG REPORT or FEATURE REQUEST?:

Uncomment only one, leave it on its own line:

/kind bug

/kind feature

What happened:

# kubectl cp
panic: runtime error: index out of range

goroutine 1 [running]:
k8s.io/kubernetes/pkg/kubectl/cmd.(*CopyOptions).Run(0xc4201b1420, 0x2420990, 0x0, 0x0, 0x0, 0x0)
	/workspace/anago-v1.11.0-beta.2.141+8745ea56e3f1f3/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/pkg/kubectl/cmd/cp.go:167 +0x483
k8s.io/kubernetes/pkg/kubectl/cmd.NewCmdCp.func1(0xc420a47b80, 0x2420990, 0x0, 0x0)
	/workspace/anago-v1.11.0-beta.2.141+8745ea56e3f1f3/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/pkg/kubectl/cmd/cp.go:96 +0x93
k8s.io/kubernetes/vendor/github.com/spf13/cobra.(*Command).execute(0xc420a47b80, 0x2420990, 0x0, 0x0, 0xc420a47b80, 0x2420990)
	/workspace/anago-v1.11.0-beta.2.141+8745ea56e3f1f3/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/vendor/github.com/spf13/cobra/command.go:760 +0x2c1
k8s.io/kubernetes/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0xc42036e280, 0xc4206423c0, 0x12a05f200, 0xc420a15ee8)
	/workspace/anago-v1.11.0-beta.2.141+8745ea56e3f1f3/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/vendor/github.com/spf13/cobra/command.go:846 +0x30a
k8s.io/kubernetes/vendor/github.com/spf13/cobra.(*Command).Execute(0xc42036e280, 0x17ecbe0, 0x2402060)
	/workspace/anago-v1.11.0-beta.2.141+8745ea56e3f1f3/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/vendor/github.com/spf13/cobra/command.go:794 +0x2b
main.main()
	/workspace/anago-v1.11.0-beta.2.141+8745ea56e3f1f3/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/cmd/kubectl/kubectl.go:50 +0x196

What you expected to happen:

I think kubectl cp should just show the help or something?

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

kubectl cp

Anything else we need to know?:

Environment:

  • Kubernetes version (use kubectl version): Client Version: version.Info{Major:"1", Minor:"11+", GitVersion:"v1.11.0-rc.1", GitCommit:"8745ea56e3f1f3ad20050c1762eb6ba6f7786675", GitTreeState:"clean", BuildDate:"2018-06-21T00:01:04Z", GoVersion:"go1.10.2", Compiler:"gc", Platform:"linux/amd64"}

  • Cloud provider or hardware configuration:

  • OS (e.g. from /etc/os-release): ubuntu 16.04 amd64

  • Kernel (e.g. uname -a): Linux hex-32c1-pm 4.4.0-122-generic #146-Ubuntu SMP Mon Apr 23 15:34:04 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

  • Install tools:

  • Others:

@gjcarneiro

This comment has been minimized.

Copy link
Author

commented Jun 26, 2018

/sig cli

@k8s-ci-robot k8s-ci-robot added sig/cli and removed needs-sig labels Jun 26, 2018

@daixiang0

This comment has been minimized.

Copy link
Contributor

commented Jun 26, 2018

It has fixed in higher version:

[root@dx-app deploy]# kubectl cp
error: 
expected 'cp <file-spec-src> <file-spec-dest> [-c container]'.
<file-spec> is:
[namespace/]pod-name:/file/path for a remote file
/file/path for a local file
See 'kubectl cp -h' for help and examples.
[root@dx-app deploy]# kubectl version
Client Version: version.Info{Major:"1", Minor:"9", GitVersion:"v1.9.7", GitCommit:"dd5e1a2978fd0b97d9b78e1564398aeea7e7fe92", GitTreeState:"clean", BuildDate:"2018-04-19T00:05:56Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"9", GitVersion:"v1.9.7", GitCommit:"dd5e1a2978fd0b97d9b78e1564398aeea7e7fe92", GitTreeState:"clean", BuildDate:"2018-04-18T23:58:35Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"linux/amd64"}
@gjcarneiro

This comment has been minimized.

Copy link
Author

commented Jun 26, 2018

You have 1.9.7, I was testing v1.11.0-rc.1. There's a regression, it seems.

Anyway, it's just a minor annoyance, it just looks ugly, that's all.

@wgliang

This comment has been minimized.

Copy link
Member

commented Jun 26, 2018

This is indeed a bug.
/assign

@tuminoid

This comment has been minimized.

Copy link

commented Jun 27, 2018

kubectl cp with some arguments crash all the way from 1.9.0 to 1.10.5 (1.8.14 is ok):

Command: kubectl cp file container: (no trailing slash):

1.9.0:

panic: runtime error: index out of range

goroutine 1 [running]:
k8s.io/kubernetes/pkg/kubectl/cmd.copyToPod(0x2a6f640, 0xc4207038c0, 0xc4202ca480, 0x2a42480, 0xc42000c018, 0x2a42480, 0xc42000c020, 0x0, 0x0, 0x0, ...)
	/go/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/pkg/kubectl/cmd/cp.go:170 +0x888
k8s.io/kubernetes/pkg/kubectl/cmd.runCopy(0x2a6f640, 0xc4207038c0, 0xc4202ca480, 0x2a42480, 0xc42000c018, 0x2a42480, 0xc42000c020, 0xc420112800, 0x2, 0x4, ...)
	/go/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/pkg/kubectl/cmd/cp.go:137 +0x23b
k8s.io/kubernetes/pkg/kubectl/cmd.NewCmdCp.func1(0xc4202ca480, 0xc420112800, 0x2, 0x4)
	/go/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/pkg/kubectl/cmd/cp.go:72 +0x89
k8s.io/kubernetes/vendor/github.com/spf13/cobra.(*Command).execute(0xc4202ca480, 0xc4201127c0, 0x4, 0x4, 0xc4202ca480, 0xc4201127c0)
	/go/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/vendor/github.com/spf13/cobra/command.go:603 +0x234
k8s.io/kubernetes/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0xc42031d200, 0x8000104, 0x0, 0xffffffffffffffff)
	/go/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/vendor/github.com/spf13/cobra/command.go:689 +0x2fe
k8s.io/kubernetes/vendor/github.com/spf13/cobra.(*Command).Execute(0xc42031d200, 0xc4207038c0, 0x2a42440)
	/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:41 +0xd5
main.main()
	/go/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/cmd/kubectl/kubectl.go:27 +0x26

1.10.5:

panic: runtime error: index out of range

goroutine 1 [running]:
k8s.io/kubernetes/pkg/kubectl/cmd.copyToPod(0x23b2840, 0xc42067bc80, 0xc420824c80, 0x2386d40, 0xc42008a008, 0x2386d40, 0xc42008a010, 0x0, 0x0, 0x0, ...)
	/workspace/anago-v1.10.5-beta.0.53+32ac1c9073b132/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/pkg/kubectl/cmd/cp.go:171 +0x888
k8s.io/kubernetes/pkg/kubectl/cmd.runCopy(0x23b2840, 0xc42067bc80, 0xc420824c80, 0x2386d40, 0xc42008a008, 0x2386d40, 0xc42008a010, 0xc420374080, 0x2, 0x4, ...)
	/workspace/anago-v1.10.5-beta.0.53+32ac1c9073b132/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/pkg/kubectl/cmd/cp.go:138 +0x23b
k8s.io/kubernetes/pkg/kubectl/cmd.NewCmdCp.func1(0xc420824c80, 0xc420374080, 0x2, 0x4)
	/workspace/anago-v1.10.5-beta.0.53+32ac1c9073b132/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/pkg/kubectl/cmd/cp.go:73 +0x89
k8s.io/kubernetes/vendor/github.com/spf13/cobra.(*Command).execute(0xc420824c80, 0xc420331040, 0x4, 0x4, 0xc420824c80, 0xc420331040)
	/workspace/anago-v1.10.5-beta.0.53+32ac1c9073b132/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/vendor/github.com/spf13/cobra/command.go:757 +0x2c1
k8s.io/kubernetes/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0xc42013d900, 0xc4208d7ed8, 0xc4208d7ee0, 0xc4204b8180)
	/workspace/anago-v1.10.5-beta.0.53+32ac1c9073b132/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/vendor/github.com/spf13/cobra/command.go:843 +0x334
k8s.io/kubernetes/vendor/github.com/spf13/cobra.(*Command).Execute(0xc42013d900, 0x1900880, 0x2552520)
	/workspace/anago-v1.10.5-beta.0.53+32ac1c9073b132/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/vendor/github.com/spf13/cobra/command.go:791 +0x2b
main.main()
	/workspace/anago-v1.10.5-beta.0.53+32ac1c9073b132/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/cmd/kubectl/kubectl.go:50 +0x196
@tuminoid

This comment has been minimized.

Copy link

commented Jun 27, 2018

Off-topic, but kubectl 1.10.5 release binary also looks funky with /workspace/anago-v1.10.5-beta.0.53+32ac1c9073b132 in the path, while up to 1.9.3 it's clean /go/. From 1.9.4 onwards it has changed to /workspace/... ?

@tuminoid

This comment has been minimized.

Copy link

commented Jun 27, 2018

Since this has fix candidate going in already, opened a separate issue for my variant: #65530

k8s-github-robot pushed a commit that referenced this issue Jul 3, 2018

Kubernetes Submit Queue
Merge pull request #65482 from wgliang/master.handle-args
Automatic merge from submit-queue. 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 'kubectl cp' with no arguments causes a panic

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

"kubectl cp" with no arguments causes a panic

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

**Special notes for your reviewer**:

**Release note**:

```release-note
Fix 'kubectl cp' with no arguments causes a panic
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.