Skip to content
This repository has been archived by the owner on Feb 8, 2021. It is now read-only.

No content returned by cat command #577

Closed
feiskyer opened this issue Apr 1, 2017 · 11 comments · Fixed by #627
Closed

No content returned by cat command #577

feiskyer opened this issue Apr 1, 2017 · 11 comments · Fixed by #627

Comments

@feiskyer
Copy link
Contributor

feiskyer commented Apr 1, 2017

While executing a container with command sh -c 'ls -al /all && cat /all/podname && cat /all/secret-data && cat /all/configmap-data', ls shows file size is not zero, but there is no content returned by following cat commands:

total 4
drwxrwxrwt    3 root     root           140 Apr  1 10:18 .
drwxr-xr-x    3 root     root          4096 Apr  1 10:18 ..
drwxr-xr-x    2 root     root           100 Apr  1 10:18 ..4984_01_04_10_18_38.047673749
lrwxrwxrwx    1 root     root            31 Apr  1 10:18 ..data -> ..4984_01_04_10_18_38.047673749
lrwxrwxrwx    1 root     root            21 Apr  1 10:18 configmap-data -> ..data/configmap-data
lrwxrwxrwx    1 root     root            14 Apr  1 10:18 podname -> ..data/podname
lrwxrwxrwx    1 root     root            18 Apr  1 10:18 secret-data -> ..data/secret-data

Releated hyperd log: hyperd.log.txt

@gnawux
Copy link
Member

gnawux commented Apr 1, 2017

could have a try with ; instead of &&? with &&, if any of the cat return non-zero, the rest command won't be executed.

@feiskyer
Copy link
Contributor Author

feiskyer commented Apr 1, 2017

@gnawux The command executes success, so there is no non-zero return code.

@gnawux
Copy link
Member

gnawux commented Apr 1, 2017

@feiskyer all the non zero size files are symlink, and can't tell if they are empty at that time.

@gnawux
Copy link
Member

gnawux commented Apr 8, 2017

any update on this issue?

@feiskyer
Copy link
Contributor Author

@laijs @gao-feng Could you help to fix the problem?

@laijs
Copy link
Contributor

laijs commented Apr 13, 2017

ls didn't show the file size zero or not, could you use ls -Lal instead please?

@feiskyer
Copy link
Contributor Author

# hyperctl logs dce0c7c9bd61fc7b53fa0936a0442e0b4c8b93e5000dfd06dd73014380db1938
total 16
drwxrwxrwt    3 root     root           140 Apr 13 03:31 .
drwxr-xr-x    3 root     root          4096 Apr 13 03:31 ..
drwxr-xr-x    2 root     root           100 Apr 13 03:31 ..4984_13_04_03_31_10.967674860
drwxr-xr-x    2 root     root           100 Apr 13 03:31 ..data
-rw-r--r--    1 root     root            17 Apr 13 03:31 configmap-data
-rw-r--r--    1 root     root             4 Apr 13 03:31 podname
-rw-r--r--    1 root     root             5 Apr 13 03:31 secret-data

@feiskyer
Copy link
Contributor Author

If the pod is started with sh and exec the same command after it has been started, the output is (which is expected above):

total 16
drwxrwxrwt    3 root     root           140 Apr 13 04:10 .
drwxr-xr-x    3 root     root          4096 Apr 13 04:10 ..
drwxr-xr-x    2 root     root           100 Apr 13 04:10 ..4984_13_04_04_10_49.294962174
drwxr-xr-x    2 root     root           100 Apr 13 04:10 ..data
-rw-r--r--    1 root     root            17 Apr 13 04:10 configmap-data
-rw-r--r--    1 root     root             5 Apr 13 04:10 podname
-rw-r--r--    1 root     root             5 Apr 13 04:10 secret-data
test2adminconfigmap-value-1

@bergwolf bergwolf self-assigned this May 2, 2017
@bergwolf
Copy link
Member

bergwolf commented May 5, 2017

If we add a newline character at the end of https://github.com/feiskyer/ops/blob/master/kubernetes/examples/projected-volume.yaml#L28, e.g., - ls -laR /all && cat /all/podname && cat /all/secret-data && echo, then the file contents will be shown.

[hypervsock@kubelet]$kubectl logs test
/all:
total 0
drwxrwxrwt    3 root     root           120 May  5 06:32 .
drwxr-xr-x    3 root     root            82 May  5 06:32 ..
drwxr-xr-x    2 root     root            80 May  5 06:32 ..5985_05_05_14_32_45.093720545
lrwxrwxrwx    1 root     root            31 May  5 06:32 ..data -> ..5985_05_05_14_32_45.093720545
lrwxrwxrwx    1 root     root            14 May  5 06:32 podname -> ..data/podname
lrwxrwxrwx    1 root     root            18 May  5 06:32 secret-data -> ..data/secret-data

/all/..5985_05_05_14_32_45.093720545:
total 8
drwxr-xr-x    2 root     root            80 May  5 06:32 .
drwxrwxrwt    3 root     root           120 May  5 06:32 ..
-rw-r--r--    1 root     root             4 May  5 06:32 podname
-rw-r--r--    1 root     root             5 May  5 06:32 secret-data
testadmin

A simple reproducer:

[hypervsock@~]$sudo hyperctl run --rm busybox echo -n foobar
foobar[hypervsock@~]$
[hypervsock@~]$sudo hyperctl run -d busybox echo -n foobar
POD id is busybox-9702672853
Time to run a POD is 6017 ms
[hypervsock@~]$sudo hyperctl logs busybox-9702672853
[hypervsock@~]$sudo cat /var/run/hyper/Pods/busybox-9702672853/8dff3adc177161430cf1a103eb8ce21cfea813724da48b647b94b50d2c4cd16c-json.log
[hypervsock@~]$

It seems the json file logger is missing container output when there is no terminating newline character.

@feiskyer
Copy link
Contributor Author

feiskyer commented May 5, 2017

@bergwolf Could we add a fix for this?

@bergwolf
Copy link
Member

bergwolf commented May 5, 2017

I'm still looking for the root cause but yes it needs to be fixed.

@bergwolf bergwolf mentioned this issue May 5, 2017
@gnawux gnawux added this to the v0.8.1 milestone May 5, 2017
@gnawux gnawux mentioned this issue May 5, 2017
@laijs laijs closed this as completed in #627 May 8, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants