diff options
author | Jacob Vosmaer <jacob@gitlab.com> | 2019-11-06 17:57:38 +0300 |
---|---|---|
committer | Jacob Vosmaer <jacob@gitlab.com> | 2019-11-06 17:57:38 +0300 |
commit | bb0cef0a62f708e60a16ad4c2e9096865434f336 (patch) | |
tree | 66076b319c150fa07795d4fce73eafb27eb7ea7d | |
parent | 0d17c2ba0499188fbe1a43bf7ef235dd48c0058a (diff) | |
parent | 56ecd5966988fd2a1b0fc63636eb791bbe627311 (diff) |
Merge branch 'jv-fix-bitmap-count' into 'master'
Bitmap counter: ignore repos without packfiles
See merge request gitlab-org/gitaly!1599
-rw-r--r-- | internal/git/bitmap.go | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/internal/git/bitmap.go b/internal/git/bitmap.go index 491937b0a..726f6f500 100644 --- a/internal/git/bitmap.go +++ b/internal/git/bitmap.go @@ -34,7 +34,7 @@ func WarnIfTooManyBitmaps(ctx context.Context, repoPath string) { return } - var count int + var bitmapCount, packCount int seen := make(map[string]bool) for _, dir := range objdirs { if seen[dir] { @@ -47,25 +47,32 @@ func WarnIfTooManyBitmaps(ctx context.Context, repoPath string) { logEntry.WithError(err).Info("bitmap check failed") return } + packCount += len(packs) for _, p := range packs { fi, err := os.Stat(strings.TrimSuffix(p, ".pack") + ".bitmap") if err == nil && !fi.IsDir() { - count++ + bitmapCount++ } } } - if count == 1 { + if bitmapCount == 1 { // Exactly one bitmap: this is how things should be. return } - if count > 1 { - logEntry.WithField("bitmaps", count).Warn("found more than one packfile bitmap in repository") + if packCount == 0 { + // If there are no packfiles we don't expect bitmaps nor do we care about + // them. + return + } + + if bitmapCount > 1 { + logEntry.WithField("bitmaps", bitmapCount).Warn("found more than one packfile bitmap in repository") } - // The case where count == 0 is likely to occur early in the life of a + // The case where bitmapCount == 0 is likely to occur early in the life of a // repository. We don't want to spam our logs with that, so we count but // not log it. @@ -74,5 +81,5 @@ func WarnIfTooManyBitmaps(ctx context.Context, repoPath string) { return } - badBitmapRequestCount.WithLabelValues(grpcMethod, strconv.Itoa(count)).Inc() + badBitmapRequestCount.WithLabelValues(grpcMethod, strconv.Itoa(bitmapCount)).Inc() } |