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

display logs for multiple containers at the same time #2620

Merged
merged 2 commits into from
Mar 16, 2019

Conversation

baude
Copy link
Member

@baude baude commented Mar 12, 2019

add the ability for users to specify more than one container at a time
while using podman logs. If more than one container is being displayed,
podman will also prepend a shortened container id of the container on
the log line.

also, enabled the podman-remote logs command during the refactoring of
the above ability.

fixes issue #2219

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

@openshift-ci-robot openshift-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 12, 2019
@openshift-ci-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: baude

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 12, 2019
@baude
Copy link
Member Author

baude commented Mar 12, 2019

@TomasTomecek ptal

cmd/podman/logs.go Outdated Show resolved Hide resolved
libpod/container_log.go Outdated Show resolved Hide resolved
libpod/container_log.go Outdated Show resolved Hide resolved
@mheon
Copy link
Member

mheon commented Mar 12, 2019

To preserve conversation from IRC, this isn't completely parsing the Kube log format, so it can't interpret P vs F lines and prints extra newlines. Also prints a few timestamp for each character when --follow and --timestamps are specified together.

Handling of control characters also seems wonky.

@TomasTomecek
Copy link
Contributor

@baude oh my, thank you so much for working on this! Can't comment on the code, but this seems to be exactly what I was asking for. One question: will --follow arg still work?

@mheon
Copy link
Member

mheon commented Mar 13, 2019

Another thing I noticed here - when following a single container, podman logs will exit immediately when the container exits currently, while this will hang forever waiting for new logs.

@baude
Copy link
Member Author

baude commented Mar 13, 2019

@baude oh my, thank you so much for working on this! Can't comment on the code, but this seems to be exactly what I was asking for. One question: will --follow arg still work?

yup!

@baude baude changed the title [wip] display logs for multiple containers at the same time display logs for multiple containers at the same time Mar 13, 2019
@openshift-ci-robot openshift-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 13, 2019
@rhatdan
Copy link
Member

rhatdan commented Mar 13, 2019

I like the idea that it hangs forever, that way if I start the container, the output will start up again.

@mheon
Copy link
Member

mheon commented Mar 13, 2019

@baude We can probably remove pkg/logs as part of this - that code shouldn't be used elsewhere

@baude baude force-pushed the multilogs branch 3 times, most recently from 404d705 to b59ab43 Compare March 14, 2019 17:31
@baude
Copy link
Member Author

baude commented Mar 14, 2019

bot, retest this please

@mheon
Copy link
Member

mheon commented Mar 14, 2019

One more thing I noticed: in the old implementation, logs --follow first printed all the logs already there, then began following; with this PR, we don't print anything old, just new log lines as they come up

@mheon
Copy link
Member

mheon commented Mar 14, 2019

Otherwise, my major concerns are addressed, output looks fine

@rhatdan
Copy link
Member

rhatdan commented Mar 15, 2019

bot, retest this please

@TomasTomecek
Copy link
Contributor

Nicely done, @baude. Just tested it locally, very nice work!

$ ./bin/podman run --rm -d --name cont1 fedora:29 bash -c 'while true; do date; sleep 1; done'
40e06045c6971c4c8452f2780e588ac468942ab3db7fcb9647435d15c8fdc453

$ ./bin/podman run --rm -d --name cont2 fedora:29 bash -c 'while true; do date; sleep 1; done'
2d66875579d62dedb0f0fdfedbeb5ba28dfad7fbe9f2b99b745e17d5f4ce940e

$ ./bin/podman logs -f cont1 cont2
40e06045c697 Fri Mar 15 16:13:43 UTC 2019
40e06045c697 Fri Mar 15 16:13:44 UTC 2019
40e06045c697 Fri Mar 15 16:13:45 UTC 2019
40e06045c697 Fri Mar 15 16:13:46 UTC 2019
40e06045c697 Fri Mar 15 16:13:47 UTC 2019
2d66875579d6 Fri Mar 15 16:13:47 UTC 2019
2d66875579d6 Fri Mar 15 16:13:48 UTC 2019

add the ability for users to specify more than one container at a time
while using podman logs.  If more than one container is being displayed,
podman will also prepend a shortened container id of the container on
the log line.

also, enabled the podman-remote logs command during the refactoring of
the above ability.

fixes issue containers#2219

Signed-off-by: baude <bbaude@redhat.com>
Wait for more than 1 second on podman info to complete.  Also, add
clarification to why slirp fails.

Signed-off-by: baude <bbaude@redhat.com>
@baude
Copy link
Member Author

baude commented Mar 15, 2019

bot, retest this please

@mheon
Copy link
Member

mheon commented Mar 15, 2019

Latest version seems to properly print all logs before following

@rhatdan
Copy link
Member

rhatdan commented Mar 16, 2019

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Mar 16, 2019
@openshift-merge-robot openshift-merge-robot merged commit 97fb495 into containers:master Mar 16, 2019
@baude baude deleted the multilogs branch December 22, 2019 18:58
@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 26, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants