diff options
author | Brent Baude <bbaude@redhat.com> | 2020-02-18 08:30:56 -0600 |
---|---|---|
committer | Brent Baude <bbaude@redhat.com> | 2020-02-20 10:22:45 -0600 |
commit | e3b31a3ab80c5f681fb157f0e10eb2d3819ef18b (patch) | |
tree | bc60e9b8f014d7de1d249aa23405320851329114 /pkg | |
parent | 8c0df03debe064f0bf6595a54d48349c79385e8b (diff) | |
download | podman-e3b31a3ab80c5f681fb157f0e10eb2d3819ef18b.tar.gz podman-e3b31a3ab80c5f681fb157f0e10eb2d3819ef18b.tar.bz2 podman-e3b31a3ab80c5f681fb157f0e10eb2d3819ef18b.zip |
implement reverse reader for log reads
in cases where the log file exceeds the available memory of a system, we had a bug that triggered an oom because the entire logfile was being read when the tail parameter was given. this reads in chunks and is more or less memory safe.
fixes: #5131
Signed-off-by: Brent Baude <bbaude@redhat.com>
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/adapter/containers.go | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/pkg/adapter/containers.go b/pkg/adapter/containers.go index 170b2e24e..ab4255f89 100644 --- a/pkg/adapter/containers.go +++ b/pkg/adapter/containers.go @@ -338,7 +338,11 @@ func (r *LocalRuntime) Log(c *cliconfig.LogsValues, options *logs.LogOptions) er if tailLen < 0 { tailLen = 0 } - logChannel := make(chan *logs.LogLine, tailLen*len(c.InputArgs)+1) + numContainers := len(c.InputArgs) + if numContainers == 0 { + numContainers = 1 + } + logChannel := make(chan *logs.LogLine, tailLen*numContainers+1) containers, err := shortcuts.GetContainersByContext(false, c.Latest, c.InputArgs, r.Runtime) if err != nil { return err |