diff options
author | Andrew Newdigate <andrew@gitlab.com> | 2017-12-01 18:04:23 +0300 |
---|---|---|
committer | Andrew Newdigate <andrew@gitlab.com> | 2017-12-01 18:04:23 +0300 |
commit | 050e36a2d65fe43d13dd630875b380918567ed22 (patch) | |
tree | 91171c48833c5b38af907eb42059f12962516c6f | |
parent | d88bfb7b328cacef19d77a6c07d76abe87243c6e (diff) |
Log more details in housekeeping
-rw-r--r-- | CHANGELOG.md | 5 | ||||
-rw-r--r-- | internal/helper/housekeeping/housekeeping.go | 22 |
2 files changed, 24 insertions, 3 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 61d39a002..7f40669ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Gitaly changelog +UNRELEASED + +- More logging in housekeeping + https://gitlab.com/gitlab-org/gitaly/merge_requests/435 + v0.56.0 - Implement UserCherryPick RPC diff --git a/internal/helper/housekeeping/housekeeping.go b/internal/helper/housekeeping/housekeeping.go index 153443dbf..3dbd119da 100644 --- a/internal/helper/housekeeping/housekeeping.go +++ b/internal/helper/housekeeping/housekeeping.go @@ -7,6 +7,7 @@ import ( "time" "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus" + log "github.com/sirupsen/logrus" "golang.org/x/net/context" ) @@ -14,9 +15,12 @@ const deleteTempFilesOlderThanDuration = 7 * 24 * time.Hour // Perform will perform housekeeping duties on a repository func Perform(ctx context.Context, repoPath string) error { - log := grpc_logrus.Extract(ctx) + logger := grpc_logrus.Extract(ctx).WithField("system", "housekeeping") - return filepath.Walk(repoPath, func(path string, info os.FileInfo, err error) error { + filesMarkedForRemoval := 0 + unremovableFiles := 0 + + err := filepath.Walk(repoPath, func(path string, info os.FileInfo, err error) error { if repoPath == path { // Never consider the root path return nil @@ -26,9 +30,12 @@ func Perform(ctx context.Context, repoPath string) error { return nil } + filesMarkedForRemoval++ + err = forceRemove(path) if err != nil { - log.WithError(err).WithField("path", path).Warn("Unable to remove stray file") + unremovableFiles++ + logger.WithError(err).WithField("path", path).Warn("unable to remove stray file") } if info.IsDir() { @@ -38,6 +45,15 @@ func Perform(ctx context.Context, repoPath string) error { return nil }) + + if filesMarkedForRemoval > 0 { + logger.WithFields(log.Fields{ + "files": filesMarkedForRemoval, + "failures": unremovableFiles, + }).Info("removed files") + } + + return err } func fixPermissions(path string) { |