Skip to content

19.03: logfile: Check if log is closed on close error during rotate#40921

Merged
thaJeztah merged 2 commits intomoby:19.03from
cpuguy83:19.03_log_rotate_error_handling
May 7, 2020
Merged

19.03: logfile: Check if log is closed on close error during rotate#40921
thaJeztah merged 2 commits intomoby:19.03from
cpuguy83:19.03_log_rotate_error_handling

Conversation

@cpuguy83
Copy link
Copy Markdown
Member

@cpuguy83 cpuguy83 commented May 6, 2020

This prevents getting into a situation where a container log cannot make
progress because we tried to rotate a file, got an error, and now the
file is closed. The next time we try to write a log entry it will try
and rotate again but error that the file is already closed.

I wonder if there is more we can do to beef up this rotation logic.
Found this issue while investigating missing logs with errors in the
docker daemon logs like:

Failed to log message for json-file: error closing file: close <file>:
file already closed

I'm not sure why the original rotation failed since the data was no
longer available.

Cherry-picks #40920

@thaJeztah thaJeztah added this to the 19.03.9 milestone May 7, 2020
@thaJeztah
Copy link
Copy Markdown
Member

pls re-cherry-pick

@cpuguy83 cpuguy83 force-pushed the 19.03_log_rotate_error_handling branch from 303e20c to b726305 Compare May 7, 2020 18:40
thaJeztah and others added 2 commits May 7, 2020 12:22
full diff: pkg/errors@v0.8.1...v0.9.1

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit dc089c2)
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
This prevents getting into a situation where a container log cannot make
progress because we tried to rotate a file, got an error, and now the
file is closed. The next time we try to write a log entry it will try
and rotate again but error that the file is already closed.

I wonder if there is more we can do to beef up this rotation logic.
Found this issue while investigating missing logs with errors in the
docker daemon logs like:

```
Failed to log message for json-file: error closing file: close <file>:
file already closed
```

I'm not sure why the original rotation failed since the data was no
longer available.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
(cherry picked from commit 3989f91)
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
@cpuguy83 cpuguy83 force-pushed the 19.03_log_rotate_error_handling branch from b726305 to 7d4dd91 Compare May 7, 2020 19:23
@cpuguy83
Copy link
Copy Markdown
Member Author

cpuguy83 commented May 7, 2020

Good to go.

@thaJeztah
Copy link
Copy Markdown
Member

Also includes one commit from #40774

Copy link
Copy Markdown
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

LGTM

@thaJeztah
Copy link
Copy Markdown
Member

@tonistiigi @tiborvass PTAL

@thaJeztah thaJeztah merged commit c4c6cf6 into moby:19.03 May 7, 2020
@cpuguy83 cpuguy83 deleted the 19.03_log_rotate_error_handling branch May 7, 2020 23:21
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.

3 participants