Skip to content

Commit

Permalink
Replace explicit type checking with a safeToWrap check in ingester
Browse files Browse the repository at this point in the history
Signed-off-by: Yuri Nikolic <durica.nikolic@grafana.com>
  • Loading branch information
duricanikolic committed Sep 14, 2023
1 parent e76234e commit eb79466
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
18 changes: 10 additions & 8 deletions pkg/ingester/ingester.go
Original file line number Diff line number Diff line change
Expand Up @@ -809,10 +809,11 @@ func (i *Ingester) PushWithCleanup(ctx context.Context, pushReq *push.Request) (

db, err := i.getOrCreateTSDB(userID, false)
if err != nil {
// Check for a particular per-instance limit and return that error directly
// since it contains extra information for gRPC and our logging middleware.
if errors.Is(err, errMaxTenantsReached) {
return nil, err
// If this is a safe error, we wrap it with userID and return it, because
// it might contain extra information for gRPC and our logging middleware.
var safe safeToWrap
if errors.As(err, &safe) {
return nil, wrapWithUser(err, userID)
}
return nil, annotateWithUser(err, userID)
}
Expand Down Expand Up @@ -859,10 +860,11 @@ func (i *Ingester) PushWithCleanup(ctx context.Context, pushReq *push.Request) (
level.Warn(i.logger).Log("msg", "failed to rollback appender on error", "user", userID, "err", err)
}

// Check for a particular per-instance limit and return that error directly
// since it contains extra information for gRPC and our logging middleware.
if errors.Is(err, errMaxInMemorySeriesReached) {
return nil, err
// If this is a safe error, we wrap it with userID and return it, because
// it might contain extra information for gRPC and our logging middleware.
var safe safeToWrap
if errors.As(err, &safe) {
return nil, wrapWithUser(err, userID)
}
return nil, annotateWithUser(err, userID)
}
Expand Down
3 changes: 1 addition & 2 deletions pkg/ingester/instance_limits.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ import (

"gopkg.in/yaml.v3"

"github.com/grafana/mimir/pkg/util/log"

"github.com/grafana/mimir/pkg/util/globalerror"
"github.com/grafana/mimir/pkg/util/log"
)

const (
Expand Down

0 comments on commit eb79466

Please sign in to comment.