moby/daemon/logger/local
Cory Snider 6d5bc07189 daemon/logger: fix refcounting decompressed files
The refCounter used for sharing temporary decompressed log files and
tracking when the files can be deleted is keyed off the source file's
path. But the path of a log file is not stable: it is renamed on each
rotation. Consequently, when logging is configured with both rotation
and compression, multiple concurrent readers of a container's logs could
read logs out of order, see duplicates or decompress a log file which
has already been decompressed.

Replace refCounter with a new implementation, sharedTempFileConverter,
which is agnostic to the file path, keying off the source file's
identity instead. Additionally, sharedTempFileConverter handles the full
lifecycle of the temporary file, from creation to deletion. This is all
abstracted from the consumer: all the bookkeeping and cleanup is handled
behind the scenes when Close() is called on the returned reader value.
Only one file descriptor is used per temporary file, which is shared by
all readers.

A channel is used for concurrency control so that the lock can be
acquired inside a select statement. While not currently utilized, this
makes it possible to add support for cancellation to
sharedTempFileConverter in the future.

Signed-off-by: Cory Snider <csnider@mirantis.com>
2022-05-19 15:22:22 -04:00
..
config.go Add new local log driver 2018-08-17 09:36:56 -07:00
doc.go Add new local log driver 2018-08-17 09:36:56 -07:00
local.go daemon/logger: open log reader synchronously 2022-05-19 15:22:22 -04:00
local_test.go daemon/logger: fix refcounting decompressed files 2022-05-19 15:22:22 -04:00
read.go daemon/logger/local: fix appending newlines 2022-05-19 15:22:22 -04:00
read_test.go test: use os.CreateTemp instead of ioutil.TempFile 2021-12-23 09:09:47 -08:00