moby/daemon/logger
Nalin Dahyabhai 513ec73831 Improve logging of long log lines
This change updates how we handle long lines of output from the
container.  The previous logic used a bufio reader to read entire lines
of output from the container through an intermediate BytesPipe, and that
allowed the container to cause dockerd to consume an unconstrained
amount of memory as it attempted to collect a whole line of output, by
outputting data without newlines.

To avoid that, we replace the bufio reader with our own buffering scheme
that handles log lines up to 16k in length, breaking up anything longer
than that into multiple chunks.  If we can dispense with noting this
detail properly at the end of output, we can switch from using
ReadBytes() to using ReadLine() instead.  We add a field ("Partial") to
the log message structure to flag when we pass data to the log driver
that did not end with a newline.

The Line member of Message structures that we pass to log drivers is now
a slice into data which can be overwritten between calls to the log
driver's Log() method, so drivers which batch up Messages before
processing them need to take additional care: we add a function
(logger.CopyMessage()) that can be used to create a deep copy of a
Message structure, and modify the awslogs driver to use it.

We update the jsonfile log driver to append a "\n" to the data that it
logs to disk only when the Partial flag is false (it previously did so
unconditionally), to make its "logs" output correctly reproduce the data
as we received it.

Likewise, we modify the journald log driver to add a data field with
value CONTAINER_PARTIAL_MESSAGE=true to entries when the Partial flag is
true, and update its "logs" reader to refrain from appending a "\n" to
the data that it retrieves if it does not see this field/value pair (it
also previously did this unconditionally).

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com> (github: nalind)
2016-06-14 14:11:47 -04:00
..
awslogs Improve logging of long log lines 2016-06-14 14:11:47 -04:00
etwlogs fix typos 2016-06-02 17:17:22 +08:00
fluentd Remove docker/ prefix from log messages tag. 2016-05-12 22:29:30 -07:00
gcplogs Do not call out to Google on init 2016-03-17 11:06:21 -04:00
gelf Remove deprecated driver specific log tags 2016-05-10 07:43:44 -07:00
journald Improve logging of long log lines 2016-06-14 14:11:47 -04:00
jsonfilelog Improve logging of long log lines 2016-06-14 14:11:47 -04:00
loggerutils Remove docker/ prefix from log messages tag. 2016-05-12 22:29:30 -07:00
splunk 1.change validateNoSchema into validateNoScheme 2016-03-31 12:29:15 +08:00
syslog Remove docker/ prefix from log messages tag. 2016-05-12 22:29:30 -07:00
context.go Remove docker/ prefix from log messages tag. 2016-05-12 22:29:30 -07:00
copier.go Improve logging of long log lines 2016-06-14 14:11:47 -04:00
copier_test.go Add a benchmark for logger.Copier 2016-06-09 09:47:13 -04:00
factory.go inherit the daemon log options when creating containers 2016-05-02 23:04:04 +08:00
logger.go Improve logging of long log lines 2016-06-14 14:11:47 -04:00