kubernetes: kubectl cp with wildcards do not work

What happened: Kubectl cp in 1.14.2 doesn’t support wildcards, despite #72641 being merged.

From container to host (trying to copy entrypoint,sh):

$ kubectl cp consul-5d98b69458-w4tzm:/entry*.sh .
tar: Removing leading `/' from member names
tar: /entry*.sh: Cannot stat: No such file or directory
tar: Exiting with failure status due to previous errors

From host to container (where * expands to 2 local files at least):

$ kubectl cp * consul-5d98b69458-w4tzm:/
error: one of src or dest must be a remote file specification

What you expected to happen: Kubectl can handle wildcards, and files are copied successfully.

How to reproduce it (as minimally and precisely as possible) Try copy even a single file with wildcard from a pod:

$ kubectl cp <pod>:/entry*.sh .

or try to copy two or more files into a pod:

kubeclt cp * <pod>:/

Anything else we need to know?: #72641 was merged without tests.

Also, passing unmatching filename wildcards to kubectl cp returns 0, while it should clearly be an error, ie. (without locally having file matching foo*):

$ kubectl cp foo* <pod>:/
$ echo $?
0

despite no files being copied.

Environment:

  • Kubernetes version (use kubectl version):
Client Version: version.Info{Major:"1", Minor:"14", GitVersion:"v1.14.2", GitCommit:"66049e3b21efe110454d67df4fa62b08ea79a19b", GitTreeState:"clean", BuildDate:"2019-05-16T16:23:09Z", GoVersion:"go1.12.5", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"14", GitVersion:"v1.14.2", GitCommit:"66049e3b21efe110454d67df4fa62b08ea79a19b", GitTreeState:"clean", BuildDate:"2019-05-16T16:14:56Z", GoVersion:"go1.12.5", Compiler:"gc", Platform:"linux/amd64"}
  • Cloud provider or hardware configuration: on-prem VM
  • OS (e.g: cat /etc/os-release): RHEL 7.6
  • Kernel (e.g. uname -a): Linux kubesingle 3.10.0-957.12.1.el7.x86_64 #1 SMP Wed Mar 20 11:34:37 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 29 (13 by maintainers)

Most upvoted comments

/reopen

This is still valid.