-
Notifications
You must be signed in to change notification settings - Fork 138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CBG-3925: Add FileLogger RotationInterval #6835
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
Redocly previews |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just minor comments.
err := runLogDeletion(ctx, logFilePath, level.String(), int(float64(*lfc.Rotation.RotatedLogsSizeLimit)*rotatedLogsLowWatermarkMultiplier), *lfc.Rotation.RotatedLogsSizeLimit) | ||
if err != nil { | ||
WarnfCtx(ctx, "%s", err) | ||
} | ||
case <-rotationTickerCh: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I think this reads just a bit easier to see rotationTicker.C
since I had to look a back to see if this was a normal ticker.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ended up writing it this way because rotationTicker
can be nil if you haven't enabled a rotation interval. The select panics trying to access C
on a nil ticker.
You can however, safely select over a nil channel, and this avoids having to write a separate conditional select if you have log rotation enabled.
require.NoError(t, err) | ||
t.Cleanup(func() { | ||
if err := os.RemoveAll(logPath); err != nil { | ||
// log instead of error because it's likely this is going to fail on Windows for this test. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// log instead of error because it's likely this is going to fail on Windows for this test. | |
// log instead of error because it's likely this is going to fail on Windows for this test if lumberjack has not finished rotation. The `time.Sleep` at the end of the tests tries to mitigate this. |
I wonder if the windows build machines are set up to clear temporary files, this could end up filing up the disks on the machine. We could consider writing to cwd if the builds do a fresh checkpoint of sync_gateway or do a git clean -fdx
Any reason here to use os.MkdirTemp
instead of t.TempDir
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
t.TempDir
fails because it asserts there was no error from RemoveAll
. I originally wrote it like that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I battled with this for a day and ended up on this solution. The sleep doesn't prevent this error, because Lumberjack keeps the current file handle open for some reason, even after calling Close()
On *nix this doesn't matter because the OS will still let us remove the file/directory.
CBG-3925
FileLogger
RotationInterval
option to force a periodic log rotation.Integration Tests
GSI=true,xattrs=true
https://jenkins.sgwdev.com/job/SyncGateway-Integration/2465/