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

podman top panics under certain conditions #169

Closed
baude opened this issue Dec 27, 2017 · 6 comments
Closed

podman top panics under certain conditions #169

baude opened this issue Dec 27, 2017 · 6 comments
Assignees
Labels
locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.

Comments

@baude
Copy link
Member

baude commented Dec 27, 2017

Under certain conditions, podman top will panic with an index out of range error. To replicate:

sudo podman run -dt -e HTTPD_VAR_RUN=/var/run/httpd -e HTTPD_MAIN_CONF_D_PATH=/etc/httpd/conf.d \
                    -e HTTPD_MAIN_CONF_PATH=/etc/httpd/conf \
                    -e HTTPD_CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/httpd/ \
                    registry.fedoraproject.org/f26/httpd /usr/bin/run-httpd

And then:

panic: runtime error: index out of range

goroutine 1 [running]:
main.psDataToPSParams(0xc42080e0d0, 0xb, 0xb, 0xc4203e0400, 0x8, 0x8, 0xc, 0x0, 0x0, 0x221d0de, ...)
	/home/cloud-user/src/github.com/projectatomic/libpod/_output/src/github.com/projectatomic/libpod/cmd/podman/top.go:151 +0x46e
main.topCmd(0xc420398160, 0x0, 0x0)
	/home/cloud-user/src/github.com/projectatomic/libpod/_output/src/github.com/projectatomic/libpod/cmd/podman/top.go:87 +0x3d9
github.com/projectatomic/libpod/vendor/github.com/urfave/cli.HandleAction(0x1ef65e0, 0x22cc488, 0xc420398160, 0x0, 0xc420248ba0)
	/home/cloud-user/src/github.com/projectatomic/libpod/_output/src/github.com/projectatomic/libpod/vendor/github.com/urfave/cli/app.go:501 +0xd2
github.com/projectatomic/libpod/vendor/github.com/urfave/cli.Command.Run(0x2218892, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2254845, 0x2c, 0x0, ...)
	/home/cloud-user/src/github.com/projectatomic/libpod/_output/src/github.com/projectatomic/libpod/vendor/github.com/urfave/cli/command.go:165 +0x505
github.com/projectatomic/libpod/vendor/github.com/urfave/cli.(*App).Run(0xc420762000, 0xc420010090, 0x3, 0x3, 0x0, 0x0)
	/home/cloud-user/src/github.com/projectatomic/libpod/_output/src/github.com/projectatomic/libpod/vendor/github.com/urfave/cli/app.go:259 +0x740
main.main()
	/home/cloud-user/src/github.com/projectatomic/libpod/_output/src/github.com/projectatomic/libpod/cmd/podman/main.go:155 +0x1112

It looks like the issue is around the default use of cmd in the ps options as removing that will allow it to work.

@baude baude self-assigned this Dec 27, 2017
@baude baude mentioned this issue Dec 28, 2017
@baude
Copy link
Member Author

baude commented Dec 28, 2017

The problem is that the CMD may contain space delimited data. i.e. http -D This throws the splitting of that line of data off by index.

@baude
Copy link
Member Author

baude commented Dec 28, 2017

@rhatdan @mheon @TomSweeneyRedHat I've been noodling on this for a while... I havent stumbled on a great way to fix this. Do you guys have any ideas?

Basically the issue is that we run a ps command inside the container and perform a strings.Field on the output which splits the string into a []string based on whitespace.

Ideally ps could identify a field delimiter but that doesn't seem to be an option. I messed with OFS and awk but I don't think it is reliable. Moving 'cmd' output to the end of the output table could be an option, but it surely doesn't output then in the order the user asked for. However, there are alias shortcuts in ps that include cmd so we could not always control it.

I also looked at the golang/psutil project and while good, it cannot support true ps options and would require a lot of wiring to make it work.

@mheon
Copy link
Member

mheon commented Dec 28, 2017

@baude It would require some refactoring, but we could use the headers of the ps output to determine where the columns are in the output line and use that to split instead - get the index of the start of each word in the header, and then split at those indexes

@baude
Copy link
Member Author

baude commented Jan 1, 2018

@mheon I looked into this a bit ... The problem I am seeing is that the column data line up is not reliable either. Consider the following:

01234567890123456789012345678901234567890
  UID   PID  PPID  C STIME TTY          TIME CMD
    0 13908 13898  0  2017 pts/0    00:01:44 top

Some line up to the header on the right, the left, and even in the middle!

@mheon
Copy link
Member

mheon commented Jan 1, 2018

@baude Oh that's just lovely. And I take it we can't guarantee that CMD will always be the last entry, either?

@baude
Copy link
Member Author

baude commented Jan 2, 2018

Nope ... think we might need to deep dive this a little deeper and see what others do

baude added a commit to baude/podman that referenced this issue Feb 5, 2018
Issue containers#169 describes a common failure when running podman top where
if the commands inside the container container a space in them, podman
will panic.  This was occuring because we take the output from ps and
attempt to format it nicely for output and things like JSON.  Given that
this cannot be predicted or dealt with programatically, the decision was
made to deprecate the format switch and simply output what ps provides
us.

Migrated top integration tests to ginkgo.

Resolves Issue: containers#169

Signed-off-by: baude <bbaude@redhat.com>
rh-atomic-bot pushed a commit that referenced this issue Feb 5, 2018
Issue #169 describes a common failure when running podman top where
if the commands inside the container container a space in them, podman
will panic.  This was occuring because we take the output from ps and
attempt to format it nicely for output and things like JSON.  Given that
this cannot be predicted or dealt with programatically, the decision was
made to deprecate the format switch and simply output what ps provides
us.

Migrated top integration tests to ginkgo.

Resolves Issue: #169

Signed-off-by: baude <bbaude@redhat.com>

Closes: #291
Approved by: rhatdan
@baude baude closed this as completed Feb 5, 2018
baude pushed a commit to baude/podman that referenced this issue Aug 31, 2019
@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 24, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.
Projects
None yet
Development

No branches or pull requests

2 participants