(err error, method string, invalidClusterValidationReporter InvalidClusterValidationReporter)
| 50 | } |
| 51 | |
| 52 | func 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. |
no test coverage detected