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

oc cp returns "No such file or directory" for filenames with escape characters #1358

Open
kgibm opened this issue Feb 28, 2023 · 2 comments
Open
Labels
lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness.

Comments

@kgibm
Copy link

kgibm commented Feb 28, 2023

A pod took a core dump:

$ oc debug node/$NODE -t
[...]
# ls -l /host/var/lib/systemd/coredump/
total 115824
-rw-r-----+ 1 root root 118596950 Feb 28 16:25 'core.Default\x20Executo.1001210000.06a2f2e0997c46b2b50bdac3c25ab072.831941.1677601537000000.lz4'

Leave the debug pod up so that we can download the file through the debug pod:

# while true; do echo "hold this pod"; sleep 8; done

Find the debug pod:

$ oc get pods --field-selector=status.phase==Running --all-namespaces | grep debug
admin2-namespace   worker1-debug       1/1     Running   0    3m54s

Downloading the core dump directory works although with a strange directory structure:

$ oc cp --namespace admin2-namespace worker1-debug:/host/var/lib/systemd/coredump/ coredumps
tar: Removing leading `/' from member names
$ tree coredumps 
coredumps
└── core.Default
    └── x20Executo.1001210000.06a2f2e0997c46b2b50bdac3c25ab072.831941.1677601537000000.lz4

However, downloading the file fails trying with various quoting and escape (client is macOS but same problem on Windows):

  1. No quoting:
    $ oc cp --namespace admin2-namespace worker1-debug:/host/var/lib/systemd/coredump/core.Default\x20Executo.1001210000.06a2f2e0997c46b2b50bdac3c25ab072.831941.1677601537000000.lz4 core.dmp.lz4
    tar: Removing leading `/' from member names
    tar: /host/var/lib/systemd/coredump/core.Defaultx20Executo.1001210000.06a2f2e0997c46b2b50bdac3c25ab072.831941.1677601537000000.lz4: Cannot stat: No such file or directory
    tar: Exiting with failure status due to previous errors
    
  2. Single quoting:
    $ oc cp --namespace admin2-namespace 'worker1-debug:/host/var/lib/systemd/coredump/core.Default\x20Executo.1001210000.06a2f2e0997c46b2b50bdac3c25ab072.831941.1677601537000000.lz4' core.dmp.lz4
    tar: Removing leading `/' from member names
    tar: /host/var/lib/systemd/coredump/core.Default/x20Executo.1001210000.06a2f2e0997c46b2b50bdac3c25ab072.831941.1677601537000000.lz4: Cannot stat: No such file or directory
    tar: Exiting with failure status due to previous errors
    
  3. Single quoting and converting \x20 to a space:
    $ oc cp --namespace admin2-namespace 'worker1-debug:/host/var/lib/systemd/coredump/core.Default Executo.1001210000.06a2f2e0997c46b2b50bdac3c25ab072.831941.1677601537000000.lz4' core.dmp.lz4
    tar: Removing leading `/' from member names
    tar: /host/var/lib/systemd/coredump/core.Default Executo.1001210000.06a2f2e0997c46b2b50bdac3c25ab072.831941.1677601537000000.lz4: Cannot stat: No such file or directory
    tar: Exiting with failure status due to previous errors
    
  4. Trying a wildcard:
    $ oc cp --namespace admin2-namespace 'worker1-debug:/host/var/lib/systemd/coredump/core.Default*.06a2f2e0997c46b2b50bdac3c25ab072.831941.1677601537000000.lz4' core.lz4
    tar: Removing leading `/' from member names
    tar: /host/var/lib/systemd/coredump/core.Default*.06a2f2e0997c46b2b50bdac3c25ab072.831941.1677601537000000.lz4: Cannot stat: No such file or directory
    tar: Exiting with failure status due to previous errors
    
  5. Double quotes doesn't return an error but doesn't download the file:
    $ oc cp --namespace admin2-namespace "worker1-debug:/host/var/lib/systemd/coredump/core.Default\x20Executo.1001210000.06a2f2e0997c46b2b50bdac3c25ab072.831941.1677601537000000.lz4" core.dmp.lz4
    $ ls core.dmp.lz4
    ls: core.dmp.lz4: No such file or directory
    

Moving the file using the debug node works but isn't great because now utilities like coredumpctl think the core dump is gone:

Debug node:

$ mv '/host/var/lib/systemd/coredump/core.Default\x20Executo.1001210000.06a2f2e0997c46b2b50bdac3c25ab072.831941.1677601537000000.lz4' '/host/var/lib/systemd/coredump/core.DefaultExecuto.1001210000.06a2f2e0997c46b2b50bdac3c25ab072.831941.1677601537000000.lz4'

Client:

$ oc cp --namespace admin2-namespace 'worker1-debug:/host/var/lib/systemd/coredump/core.DefaultExecuto.1001210000.06a2f2e0997c46b2b50bdac3c25ab072.831941.1677601537000000.lz4' core.dmp.lz4 
tar: Removing leading `/' from member names
$ ls -l core.dmp.lz4
-rw-r--r--  1 kevin  wheel  118596950 Feb 28 13:29 core.dmp.lz4

oc version:

$ oc version
Client Version: 4.11.0-0.nightly-2022-05-18-171831
Kustomize Version: v4.5.4
Server Version: 4.11.21
Kubernetes Version: v1.24.6+5658434
@openshift-bot
Copy link
Contributor

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

@openshift-ci openshift-ci bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label May 30, 2023
@kgibm
Copy link
Author

kgibm commented May 30, 2023

/lifecycle frozen

This is a continuing and significant impact, particularly for products that commonly have spaces in the thread name. This issue leads to complicated workarounds.

@openshift-ci openshift-ci bot added lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels May 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness.
Projects
None yet
Development

No branches or pull requests

2 participants