MCPcopy
hub / github.com/grafana/dskit / handleClusterValidationError

Function handleClusterValidationError

middleware/grpc_cluster.go:52–69  ·  view source on GitHub ↗
(err error, method string, invalidClusterValidationReporter InvalidClusterValidationReporter)

Source from the content-addressed store, hash-verified

50}
51
52func handleClusterValidationError(err error, method string, invalidClusterValidationReporter InvalidClusterValidationReporter) error {
53 if err == nil {
54 return nil
55 }
56 if stat, ok := grpcutil.ErrorToStatus(err); ok {
57 details := stat.Details()
58 if len(details) == 1 {
59 if errDetails, ok := details[0].(*grpcutil.ErrorDetails); ok {
60 if errDetails.GetCause() == grpcutil.WRONG_CLUSTER_VALIDATION_LABEL {
61 msg := fmt.Sprintf("request rejected by the server: %s", stat.Message())
62 invalidClusterValidationReporter(msg, method)
63 return grpcutil.Status(codes.Internal, msg).Err()
64 }
65 }
66 }
67 }
68 return err
69}
70
71// ClusterUnaryServerInterceptor checks if the incoming gRPC metadata contains any cluster label and if so, checks if
72// the latter corresponds to one of the given cluster labels. If it is the case, the request is further propagated.

Callers 1

Calls 5

ErrorToStatusFunction · 0.92
StatusFunction · 0.92
GetCauseMethod · 0.80
MessageMethod · 0.80
ErrMethod · 0.45

Tested by

no test coverage detected