diff options
author | cdoern <cdoern@redhat.com> | 2021-07-06 14:53:56 -0400 |
---|---|---|
committer | cdoern <cdoern@redhat.com> | 2021-07-22 10:56:56 -0400 |
commit | 0f708efd8be843e06dd8a0ac68101a875a82c90e (patch) | |
tree | a1869f32538963daa6c4702115a82174ccf4eb85 /libpod | |
parent | 4fb4614cf14a362c047b17612488fbdc0dc8e253 (diff) | |
download | podman-0f708efd8be843e06dd8a0ac68101a875a82c90e.tar.gz podman-0f708efd8be843e06dd8a0ac68101a875a82c90e.tar.bz2 podman-0f708efd8be843e06dd8a0ac68101a875a82c90e.zip |
Implemented --until flag for libpod's container logs
compat containers/logs was missing actual usage of until query param.
This led me to implement the until param for libpod's container logs as well. Added e2e tests.
Signed-off-by: cdoern <cdoern@redhat.com>
Diffstat (limited to 'libpod')
-rw-r--r-- | libpod/container_log_linux.go | 19 |
1 files changed, 3 insertions, 16 deletions
diff --git a/libpod/container_log_linux.go b/libpod/container_log_linux.go index 9f9dd3b0d..d4afaa52a 100644 --- a/libpod/container_log_linux.go +++ b/libpod/container_log_linux.go @@ -97,8 +97,6 @@ func (c *Container) readFromJournal(ctx context.Context, options *logs.LogOption } }() - beforeTimeStamp := true - afterTimeStamp := false // needed for options.Since tailQueue := []*logs.LogLine{} // needed for options.Tail doTail := options.Tail > 0 for { @@ -150,21 +148,10 @@ func (c *Container) readFromJournal(ctx context.Context, options *logs.LogOption return } - if !afterTimeStamp { - entryTime := time.Unix(0, int64(entry.RealtimeTimestamp)*int64(time.Microsecond)) - if entryTime.Before(options.Since) { - continue - } - afterTimeStamp = true - } - if beforeTimeStamp { - entryTime := time.Unix(0, int64(entry.RealtimeTimestamp)*int64(time.Microsecond)) - if entryTime.Before(options.Until) || !options.Until.IsZero() { - continue - } - beforeTimeStamp = false + entryTime := time.Unix(0, int64(entry.RealtimeTimestamp)*int64(time.Microsecond)) + if (entryTime.Before(options.Since) && !options.Since.IsZero()) || (entryTime.After(options.Until) && !options.Until.IsZero()) { + continue } - // If we're reading an event and the container exited/died, // then we're done and can return. event, ok := entry.Fields["PODMAN_EVENT"] |