Skip to content

[20.10 backport] Handle long log messages correctly on SizedLogger#41975

Merged
cpuguy83 merged 1 commit into
moby:20.10from
thaJeztah:20.10_backport_41794_sized_logger
Feb 18, 2021
Merged

[20.10 backport] Handle long log messages correctly on SizedLogger#41975
cpuguy83 merged 1 commit into
moby:20.10from
thaJeztah:20.10_backport_41794_sized_logger

Conversation

@thaJeztah

Copy link
Copy Markdown
Member

backport of #41909

fixes #41794 "awslogs" driver with "non-blocking" mode cause log events to split larger then 16k size

Loggers that implement BufSize() (e.g. awslogs) uses the method to
tell Copier about the maximum log line length. However loggerWithCache
and RingBuffer hide the method by wrapping loggers.

As a result, Copier uses its default 16KB limit which breaks log
lines > 16kB even the destinations can handle that.

This change implements BufSize() on loggerWithCache and RingBuffer to
make sure these logger wrappes don't hide the method on the underlying
loggers.

Fixes #41794.

Signed-off-by: Kazuyoshi Kato [email protected]

- What I did

I've added BufSize() to loggerWithCache and RingLogger to make Copier aware about the size limit of the underlying loggers.

- How I did it

I've added the method to the structs.

- How to verify it

I built Docker and tested the change with log-split container image I made.

docker run -d --log-driver=awslogs --log-opt mode=non-blocking --log-opt awslogs-group="log-split-test" --log-opt awslogs-region=us-west-2 log-split:latest

The Dockerfile for the image is below.

FROM ubuntu:18.04
CMD tr -dc A-Za-z0-9 </dev/urandom | head -c 17000; echo ''

I also added new unit tests on Copier.

- Description for the changelog

Fix loggers to make sure they don't break long lines when the destinations' limits allow.

@thaJeztah thaJeztah added this to the 20.10.4 milestone Feb 3, 2021
@thaJeztah
thaJeztah requested a review from cpuguy83 February 3, 2021 13:32
@thaJeztah

Copy link
Copy Markdown
Member Author

@samuelkarp @kzys @estesp ptal

@thaJeztah
thaJeztah requested a review from estesp February 3, 2021 13:37

@estesp estesp left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Loggers that implement BufSize() (e.g. awslogs) uses the method to
tell Copier about the maximum log line length. However loggerWithCache
and RingBuffer hide the method by wrapping loggers.

As a result, Copier uses its default 16KB limit which breaks log
lines > 16kB even the destinations can handle that.

This change implements BufSize() on loggerWithCache and RingBuffer to
make sure these logger wrappes don't hide the method on the underlying
loggers.

Fixes moby#41794.

Signed-off-by: Kazuyoshi Kato <[email protected]>
(cherry picked from commit bb11365)
Signed-off-by: Sebastiaan van Stijn <[email protected]>
@thaJeztah
thaJeztah force-pushed the 20.10_backport_41794_sized_logger branch from 351ba50 to d13e162 Compare February 17, 2021 20:19
@thaJeztah

Copy link
Copy Markdown
Member Author

rebased to trigger CI with test-fixes that were merged

@cpuguy83 cpuguy83 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@cpuguy83
cpuguy83 merged commit 24e1d7f into moby:20.10 Feb 18, 2021
@thaJeztah
thaJeztah deleted the 20.10_backport_41794_sized_logger branch February 18, 2021 00:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants