Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get rid of httpgrpc on distributor's write path #6377

Merged
merged 6 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions pkg/distributor/distributor.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (

"github.com/go-kit/log"
"github.com/go-kit/log/level"
"github.com/gogo/status"
"github.com/grafana/dskit/httpgrpc"
"github.com/grafana/dskit/instrument"
"github.com/grafana/dskit/kv"
Expand Down Expand Up @@ -1089,15 +1090,30 @@ func (d *Distributor) handlePushError(ctx context.Context, pushErr error) error
return pushErr
}

if errors.Is(pushErr, context.DeadlineExceeded) {
return pushErr
}

// TODO This code is needed for backwards compatibility, since ingesters may still return
// errors created by httpgrpc.Errorf(). If pushErr is one of those errors, we just propagate
// it. This code should be removed once that creation is removed from the ingesters.
_, ok := httpgrpc.HTTPResponseFromError(pushErr)
if ok {
return pushErr
}
// If pushErr is already a gRPC (for example returned by the ingester), we just propagate it.
// TODO this should be updated once the ingester error handling is improved.
_, ok = status.FromError(pushErr)
if ok {
return pushErr
}

serviceOverloadErrorEnabled := false
userID, err := tenant.TenantID(ctx)
if err == nil {
serviceOverloadErrorEnabled = d.limits.ServiceOverloadStatusCodeOnRateLimitEnabled(userID)
}
if httpStatus, ok := toHTTPStatus(pushErr, serviceOverloadErrorEnabled); ok {
return httpgrpc.Errorf(httpStatus, pushErr.Error())
}
return pushErr
return toGRPCError(pushErr, serviceOverloadErrorEnabled)
}

// push takes a write request and distributes it to ingesters using the ring.
Expand Down Expand Up @@ -1191,7 +1207,7 @@ func (d *Distributor) push(ctx context.Context, pushReq *Request) error {

err := d.send(localCtx, ingester, timeseries, metadata, req.Source)
if errors.Is(err, context.DeadlineExceeded) {
return httpgrpc.Errorf(500, "exceeded configured distributor remote timeout: %s", err.Error())
return errors.Wrap(err, deadlineExceededWrapMessage)
}
return err
}, func() { pushReq.CleanUp(); cancel() })
Expand Down
Loading
Loading