Skip to content

Commit 69952a3

Browse files
committed
s3cache: count S3 write-behind errors
Also, don't repeat the already-logged error from Wait.
1 parent 14ab936 commit 69952a3

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

s3cache/s3cache.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ type Cache struct {
8686
putS3Found expvar.Int // count of objects not written to S3 because they were already present
8787
putS3Action expvar.Int // count of actions written to S3
8888
putS3Object expvar.Int // count of objects written to S3
89+
putS3Error expvar.Int // count of errors writing to S3
8990
}
9091

9192
func (s *Cache) init() {
@@ -200,9 +201,8 @@ func (s *Cache) Close(ctx context.Context) error {
200201
if s.push != nil {
201202
gocache.Logf(ctx, "waiting for uploads...")
202203
wstart := time.Now()
203-
err := s.push.Wait()
204-
gocache.Logf(ctx, "uploads complete (%v elapsed, err=%v)",
205-
time.Since(wstart).Round(10*time.Microsecond), err)
204+
s.push.Wait()
205+
gocache.Logf(ctx, "uploads complete (%v elapsed)", time.Since(wstart).Round(10*time.Microsecond))
206206
}
207207
return nil
208208
}
@@ -216,6 +216,7 @@ func (s *Cache) SetMetrics(_ context.Context, m *expvar.Map) {
216216
m.Set("put_s3_found", &s.putS3Found)
217217
m.Set("put_s3_action", &s.putS3Action)
218218
m.Set("put_s3_object", &s.putS3Object)
219+
m.Set("put_s3_error", &s.putS3Error)
219220
}
220221

221222
// maybePutObject writes the specified object contents to S3 if there is not
@@ -248,6 +249,7 @@ func (s *Cache) maybePutObject(ctx context.Context, objectID, diskPath, etag str
248249
Key: s.objectKey(objectID),
249250
Body: f,
250251
}); err != nil {
252+
s.putS3Error.Add(1)
251253
gocache.Logf(ctx, "[s3] put object %s: %v", objectID, err)
252254
return fi.ModTime(), err
253255
}

0 commit comments

Comments
 (0)