Skip to content

Commit 49f332d

Browse files
authored
Store: If request ctx has an error we do not increment opsFailures counter (#3179)
* Store: If request ctx has an error we do not increment opsFailures counter Signed-off-by: Jarod Watkins <[email protected]> * Using context.Canceled Signed-off-by: Jarod Watkins <[email protected]> * Updating CHANGELOG Signed-off-by: Jarod Watkins <[email protected]>
1 parent a11b790 commit 49f332d

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ We use *breaking :warning:* to mark changes that are not backward compatible (re
2626
- [#3136](https://github.com/thanos-io/thanos/pull/3136) Sidecar: Add metric `thanos_sidecar_reloader_config_apply_operations_total` and rename metric `thanos_sidecar_reloader_config_apply_errors_total` to `thanos_sidecar_reloader_config_apply_operations_failed_total`.
2727
- [#3154](https://github.com/thanos-io/thanos/pull/3154) Query: Add metric `thanos_query_gate_queries_max`. Remove metric `thanos_query_concurrent_selects_gate_queries_in_flight`.
2828
- [#3154](https://github.com/thanos-io/thanos/pull/3154) Store: Rename metric `thanos_bucket_store_queries_concurrent_max` to `thanos_bucket_store_series_gate_queries_max`.
29+
- [#3179](https://github.com/thanos-io/thanos/pull/3179) Store: context.Canceled will not increase `thanos_objstore_bucket_operation_failures_total`.
2930

3031
## [v0.15.0](https://github.com/thanos-io/thanos/releases) - 2020.09.07
3132

pkg/objstore/objstore.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -312,8 +312,10 @@ func (b *metricBucket) Iter(ctx context.Context, dir string, f func(name string)
312312
b.ops.WithLabelValues(op).Inc()
313313

314314
err := b.bkt.Iter(ctx, dir, f)
315-
if err != nil && !b.isOpFailureExpected(err) {
316-
b.opsFailures.WithLabelValues(op).Inc()
315+
if err != nil {
316+
if !b.isOpFailureExpected(err) && ctx.Err() != context.Canceled {
317+
b.opsFailures.WithLabelValues(op).Inc()
318+
}
317319
}
318320
return err
319321
}
@@ -325,7 +327,7 @@ func (b *metricBucket) Attributes(ctx context.Context, name string) (ObjectAttri
325327
start := time.Now()
326328
attrs, err := b.bkt.Attributes(ctx, name)
327329
if err != nil {
328-
if !b.isOpFailureExpected(err) {
330+
if !b.isOpFailureExpected(err) && ctx.Err() != context.Canceled {
329331
b.opsFailures.WithLabelValues(op).Inc()
330332
}
331333
return attrs, err
@@ -340,7 +342,7 @@ func (b *metricBucket) Get(ctx context.Context, name string) (io.ReadCloser, err
340342

341343
rc, err := b.bkt.Get(ctx, name)
342344
if err != nil {
343-
if !b.isOpFailureExpected(err) {
345+
if !b.isOpFailureExpected(err) && ctx.Err() != context.Canceled {
344346
b.opsFailures.WithLabelValues(op).Inc()
345347
}
346348
return nil, err
@@ -360,7 +362,7 @@ func (b *metricBucket) GetRange(ctx context.Context, name string, off, length in
360362

361363
rc, err := b.bkt.GetRange(ctx, name, off, length)
362364
if err != nil {
363-
if !b.isOpFailureExpected(err) {
365+
if !b.isOpFailureExpected(err) && ctx.Err() != context.Canceled {
364366
b.opsFailures.WithLabelValues(op).Inc()
365367
}
366368
return nil, err
@@ -381,7 +383,7 @@ func (b *metricBucket) Exists(ctx context.Context, name string) (bool, error) {
381383
start := time.Now()
382384
ok, err := b.bkt.Exists(ctx, name)
383385
if err != nil {
384-
if !b.isOpFailureExpected(err) {
386+
if !b.isOpFailureExpected(err) && ctx.Err() != context.Canceled {
385387
b.opsFailures.WithLabelValues(op).Inc()
386388
}
387389
return false, err
@@ -396,7 +398,7 @@ func (b *metricBucket) Upload(ctx context.Context, name string, r io.Reader) err
396398

397399
start := time.Now()
398400
if err := b.bkt.Upload(ctx, name, r); err != nil {
399-
if !b.isOpFailureExpected(err) {
401+
if !b.isOpFailureExpected(err) && ctx.Err() != context.Canceled {
400402
b.opsFailures.WithLabelValues(op).Inc()
401403
}
402404
return err
@@ -412,7 +414,7 @@ func (b *metricBucket) Delete(ctx context.Context, name string) error {
412414

413415
start := time.Now()
414416
if err := b.bkt.Delete(ctx, name); err != nil {
415-
if !b.isOpFailureExpected(err) {
417+
if !b.isOpFailureExpected(err) && ctx.Err() != context.Canceled {
416418
b.opsFailures.WithLabelValues(op).Inc()
417419
}
418420
return err

0 commit comments

Comments
 (0)