chore: add logging to Filestore.purger#26089
Conversation
devanbenz
left a comment
There was a problem hiding this comment.
Just a few code nits and a question about logging file names post purge.
| removeErr := c.RemoveTmpFiles(files) | ||
| if removeErr == nil { | ||
| return errors.Join(originalErrs...) | ||
| if len(originalErrs) == 1 { |
There was a problem hiding this comment.
Is this required? Wouldn't errors.Join(originalErrs...) capture a single error?
There was a problem hiding this comment.
It does, but this is a quick hack to allow older code looking for a specific error by casting instead of using errors.Is to continue to function.
| e := errors.Unwrap(err) | ||
| assert.NotNil(t, e, "expected an error wrapped by errCompactionInProgress") | ||
| assert.Truef(t, errors.Is(e, fs.ErrExist), "error did not indicate file existence: %v", e) | ||
| assert.ErrorContains(t, err, "file exists", "unexpected error writing snapshot for %s", f2Name) |
There was a problem hiding this comment.
assert.ErrorContainsf for string formatting?
| go func() { | ||
| var purgeCount int | ||
| defer func() { | ||
| logger.Info("removed", zap.Int("files", purgeCount)) |
There was a problem hiding this comment.
Would it be a good idea to log out the file names that were removed as well as the count? I see we log the names out above, this may make it easier to compare the lists in the logs if any issues arise.
There was a problem hiding this comment.
We print them out as they are deleted when the log level is debug
Also fixes error type checks in TestCompactor_CompactFull_InProgress (cherry picked from commit 2ab5aad)
|
I like the logging and error improvements here! they are much better than what was there. I note several other issues though in the purging code (not related to the pr changes)
EDIT: extracted into ticket |
Also fixes error type checks in
TestCompactor_CompactFull_InProgress