24 Commits

Author SHA1 Message Date
b7f699c199 Fix podman logs read partial log lines
If a partial log line has the length 1 it was ignored by podman logs.

Fixes #8879

Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
2021-01-07 00:04:38 +01:00
4fa1fce930 Spelling
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>
2020-12-22 13:34:31 -05:00
a5e37ad280 Switch all references to github.com/containers/libpod -> podman
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-07-28 08:23:45 -04:00
09dc77aedf log API: add context to allow for cancelling
Add a `context.Context` to the log APIs to allow for cancelling
streaming (e.g., via `podman logs -f`).  This fixes issues for
the remote API where some go routines of the server will continue
writing and produce nothing but heat and waste CPU cycles.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-07-09 15:13:07 +02:00
8489dc4345 move go module to v2
With the advent of Podman 2.0.0 we crossed the magical barrier of go
modules.  While we were able to continue importing all packages inside
of the project, the project could not be vendored anymore from the
outside.

Move the go module to new major version and change all imports to
`github.com/containers/libpod/v2`.  The renaming of the imports
was done via `gomove` [1].

[1] https://github.com/KSubedi/gomove

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-07-06 15:50:12 +02:00
8926e1f03b Use POLL_DURATION for timer
Signed-off-by: jgallucci32 <john.gallucci.iv@gmail.com>
2020-06-21 09:31:22 -07:00
78dd4f2ecb Stop following logs using timers
This incorporates code from PR #6591 and #6614 but does not use
event channels to detect container state and rather uses timers
with a defined wait duration before calling t.StopAtEOF() to
ensure the last log entry is output before a container exits.

The polling interval is set to 250 milliseconds based on polling
interval defined in hpcloud/tail here:
https://github.com/hpcloud/tail/blob/v1.0.0/watch/polling.go#L117

Co-authored-by: Qi Wang <qiwan@redhat.com>
Signed-off-by: jgallucci32 <john.gallucci.iv@gmail.com>
2020-06-20 09:48:55 -07:00
7b00e49f65 Merge pull request #6560 from mheon/fix_exec_logdriver
Do not share container log driver for exec
2020-06-17 17:17:27 -04:00
03e99c9b40 Revert #6591 to fix issue with failed tests
Signed-off-by: jgallucci32 <john.gallucci.iv@gmail.com>
2020-06-17 08:31:09 -07:00
0e171b7b33 Do not share container log driver for exec
When the container uses journald logging, we don't want to
automatically use the same driver for its exec sessions. If we do
we will pollute the journal (particularly in the case of
healthchecks) with large amounts of undesired logs. Instead,
force exec sessions logs to file for now; we can add a log-driver
flag later (we'll probably want to add a `podman logs` command
that reads exec session logs at the same time).

As part of this, add support for the new 'none' logs driver in
Conmon. It will be the default log driver for exec sessions, and
can be optionally selected for containers.

Great thanks to Joe Gooch (mrwizard@dok.org) for adding support
to Conmon for a null log driver, and wiring it in here.

Fixes #6555

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2020-06-17 11:11:46 -04:00
6d9863e773 Remove redundant break in for loop.
Remove redundant `break` call in for loop.

Co-authored-by: Qi Wang <qiwan@redhat.com>
Signed-off-by: jgallucci32 <john.gallucci.iv@gmail.com>
2020-06-15 07:42:05 -07:00
d514e3c097 Do not print error message when container does not exist
This fixes a condition when a container is removed while
following the logs and prints an error when the container
is removed forcefully.

Signed-off-by: jgallucci32 <john.gallucci.iv@gmail.com>
2020-06-12 12:59:58 -07:00
e714352501 Changed from t.StopAtEOF() to t.Stop() and added error check
Signed-off-by: jgallucci32 <john.gallucci.iv@gmail.com>
2020-06-12 11:10:08 -07:00
9ac115e691 Fix -f logs to stop when a container exits
Fixes an issue with the previous PR where a container would exit while following logs and the log tail continued to follow. This creates a subroutine which checks the state of the container and instructs the tailLog to stop when it reaches EOF.

Tested the following conditions:
* Tail and follow logs of running container
* Tail and follow logs of stopped container
* Tail and follow logs of running container which exits after some time

Signed-off-by: jgallucci32 <john.gallucci.iv@gmail.com>
2020-06-12 10:14:35 -07:00
033743cbee Fix -f logs follow with stopped container
Fix -f logs follow with stopped container. Close #6531

Signed-off-by: Qi Wang <qiwan@redhat.com>
2020-06-11 17:55:26 -04:00
86ffa552d2 Fixed bug where 'podman log <container>' would truncate some lines.
Signed-off-by: Will Haines <william.haines@colorado.edu>
2020-06-10 15:08:48 -06:00
ba430bfe5e podman v2 remove bloat v2
rid ourseleves of libpod references in v2 client

Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-04-16 12:04:46 -05:00
8561b99644 libpod removal from main (phase 2)
this is phase 2 for the removal of libpod from main.

Signed-off-by: baude <bbaude@redhat.com>
2019-06-27 07:56:24 -05:00
88429242dd Add --follow to journald ctr logging
Signed-off-by: Peter Hunt <pehunt@redhat.com>
2019-05-28 11:14:08 -04:00
51bdf29f04 Address comments
Signed-off-by: Peter Hunt <pehunt@redhat.com>
2019-05-28 11:10:57 -04:00
02f971131a Implement podman logs with log-driver journald
Add a journald reader that translates the journald entry to a k8s-file formatted line, to be added as a log line

Note: --follow with journald hasn't been implemented. It's going to be a larger undertaking that can wait.

Signed-off-by: Peter Hunt <pehunt@redhat.com>
2019-05-28 11:10:57 -04:00
f61fa28d39 Added --log-driver and journald logging
Signed-off-by: Peter Hunt <pehunt@redhat.com>
2019-05-28 11:10:57 -04:00
46f18764f2 podman logs on created container should exit
when running podman logs on a created container (which has no logs),
podman should return gracefully (like docker) with a 0 return code. if
multiple containers are provided and one is only in the created state
(and no follow is used), we still display the logs for the other ids.

fixes issue #2677

Signed-off-by: baude <bbaude@redhat.com>
2019-03-18 08:58:48 -05:00
5e86acd591 display logs for multiple containers at the same time
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>
2019-03-15 13:41:01 -05:00