mirror of
https://github.com/googleforgames/open-match.git
synced 2025-03-25 13:24:18 +00:00
Light reduction of log spam from errors. (#573)
This commit is contained in:
@ -57,7 +57,7 @@ type mmfResult struct {
|
||||
}
|
||||
|
||||
var (
|
||||
logger = logrus.WithFields(logrus.Fields{
|
||||
backendServiceLogger = logrus.WithFields(logrus.Fields{
|
||||
"app": "openmatch",
|
||||
"component": "app.backend.backend_service",
|
||||
})
|
||||
@ -84,9 +84,11 @@ func newBackendService(cfg config.View) (*backendService, error) {
|
||||
// FetchMatches returns nil unless the context is canceled. FetchMatches moves to the next response candidate if it encounters
|
||||
// any internal execution failures.
|
||||
func (s *backendService) FetchMatches(ctx context.Context, req *pb.FetchMatchesRequest) (*pb.FetchMatchesResponse, error) {
|
||||
if req.GetConfig() == nil || req.GetProfile() == nil {
|
||||
logger.Error("invalid argument, function config or input profiles is nil")
|
||||
return nil, status.Errorf(codes.InvalidArgument, "invalid argument, function config or input profiles is nil")
|
||||
if req.GetConfig() == nil {
|
||||
return nil, status.Error(codes.InvalidArgument, ".config is required")
|
||||
}
|
||||
if req.GetProfile() == nil {
|
||||
return nil, status.Error(codes.InvalidArgument, ".profile is required")
|
||||
}
|
||||
|
||||
resultChan := make(chan mmfResult, len(req.GetProfile()))
|
||||
@ -140,7 +142,7 @@ func doFetchMatchesInChannel(ctx context.Context, cfg config.View, mmfClients *s
|
||||
case pb.FunctionConfig_GRPC:
|
||||
grpcClient, err = getGRPCClient(cfg, mmfClients, address)
|
||||
if err != nil {
|
||||
logger.WithFields(logrus.Fields{
|
||||
backendServiceLogger.WithFields(logrus.Fields{
|
||||
"error": err.Error(),
|
||||
"function": req.GetConfig(),
|
||||
}).Error("failed to establish grpc client connection to match function")
|
||||
@ -150,14 +152,13 @@ func doFetchMatchesInChannel(ctx context.Context, cfg config.View, mmfClients *s
|
||||
case pb.FunctionConfig_REST:
|
||||
httpClient, baseURL, err = getHTTPClient(cfg, mmfClients, address)
|
||||
if err != nil {
|
||||
logger.WithFields(logrus.Fields{
|
||||
backendServiceLogger.WithFields(logrus.Fields{
|
||||
"error": err.Error(),
|
||||
"function": req.GetConfig(),
|
||||
}).Error("failed to establish rest client connection to match function")
|
||||
return status.Error(codes.InvalidArgument, "failed to connect to match function")
|
||||
}
|
||||
default:
|
||||
logger.Error("unsupported function type provided")
|
||||
return status.Error(codes.InvalidArgument, "provided match function type is not supported")
|
||||
}
|
||||
|
||||
@ -207,9 +208,6 @@ func getHTTPClient(cfg config.View, mmfClients *sync.Map, addr string) (*http.Cl
|
||||
}
|
||||
data = httpData{client, baseURL}
|
||||
mmfClients.Store(addr, data)
|
||||
logger.WithFields(logrus.Fields{
|
||||
"address": addr,
|
||||
}).Info("successfully connected to the HTTP match function service")
|
||||
}
|
||||
return data.client, data.baseURL, nil
|
||||
}
|
||||
@ -224,9 +222,6 @@ func getGRPCClient(cfg config.View, mmfClients *sync.Map, addr string) (pb.Match
|
||||
}
|
||||
data = grpcData{pb.NewMatchFunctionClient(conn)}
|
||||
mmfClients.Store(addr, data)
|
||||
logger.WithFields(logrus.Fields{
|
||||
"address": addr,
|
||||
}).Info("successfully connected to the GRPC match function service")
|
||||
}
|
||||
|
||||
return data.client, nil
|
||||
@ -255,7 +250,7 @@ func matchesFromHTTPMMF(ctx context.Context, profile *pb.MatchProfile, client *h
|
||||
defer func() {
|
||||
err = resp.Body.Close()
|
||||
if err != nil {
|
||||
logger.WithError(err).Error("failed to close response body read closer")
|
||||
backendServiceLogger.WithError(err).Warning("failed to close response body read closer")
|
||||
}
|
||||
}()
|
||||
|
||||
@ -281,7 +276,7 @@ func matchesFromGRPCMMF(ctx context.Context, profile *pb.MatchProfile, client pb
|
||||
// and timeout gracefully to ensure that the ListMatches completes.
|
||||
resp, err := client.Run(ctx, &pb.RunRequest{Profile: profile})
|
||||
if err != nil {
|
||||
logger.WithError(err).Error("failed to run match function for profile")
|
||||
backendServiceLogger.WithError(err).Error("failed to run match function for profile")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@ -293,7 +288,7 @@ func matchesFromGRPCMMF(ctx context.Context, profile *pb.MatchProfile, client pb
|
||||
func (s *backendService) AssignTickets(ctx context.Context, req *pb.AssignTicketsRequest) (*pb.AssignTicketsResponse, error) {
|
||||
err := doAssignTickets(ctx, req, s.store)
|
||||
if err != nil {
|
||||
logger.WithError(err).Error("failed to update assignments for requested tickets")
|
||||
backendServiceLogger.WithError(err).Error("failed to update assignments for requested tickets")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@ -303,7 +298,7 @@ func (s *backendService) AssignTickets(ctx context.Context, req *pb.AssignTicket
|
||||
func doAssignTickets(ctx context.Context, req *pb.AssignTicketsRequest, store statestore.Service) error {
|
||||
err := store.UpdateAssignments(ctx, req.GetTicketId(), req.GetAssignment())
|
||||
if err != nil {
|
||||
logger.WithError(err).Error("failed to update assignments")
|
||||
backendServiceLogger.WithError(err).Error("failed to update assignments")
|
||||
return err
|
||||
}
|
||||
for _, id := range req.GetTicketId() {
|
||||
@ -311,7 +306,7 @@ func doAssignTickets(ctx context.Context, req *pb.AssignTicketsRequest, store st
|
||||
// Try to deindex all input tickets. Log without returning an error if the deindexing operation failed.
|
||||
// TODO: consider retry the index operation
|
||||
if err != nil {
|
||||
logger.WithError(err).Errorf("failed to deindex ticket %s after updating the assignments", id)
|
||||
backendServiceLogger.WithError(err).Errorf("failed to deindex ticket %s after updating the assignments", id)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@ type frontendService struct {
|
||||
}
|
||||
|
||||
var (
|
||||
logger = logrus.WithFields(logrus.Fields{
|
||||
frontendServiceLogger = logrus.WithFields(logrus.Fields{
|
||||
"app": "openmatch",
|
||||
"component": "app.frontend.frontend_service",
|
||||
})
|
||||
@ -48,8 +48,7 @@ var (
|
||||
func (s *frontendService) CreateTicket(ctx context.Context, req *pb.CreateTicketRequest) (*pb.CreateTicketResponse, error) {
|
||||
// Perform input validation.
|
||||
if req.GetTicket() == nil {
|
||||
logger.Error("invalid argument - ticket cannot be nil")
|
||||
return nil, status.Errorf(codes.InvalidArgument, "ticket cannot be nil")
|
||||
return nil, status.Errorf(codes.InvalidArgument, ".ticket is required")
|
||||
}
|
||||
|
||||
return doCreateTicket(ctx, req, s.store)
|
||||
@ -59,14 +58,13 @@ func doCreateTicket(ctx context.Context, req *pb.CreateTicketRequest, store stat
|
||||
// Generate a ticket id and create a Ticket in state storage
|
||||
ticket, ok := proto.Clone(req.Ticket).(*pb.Ticket)
|
||||
if !ok {
|
||||
logger.Error("failed to clone input ticket proto")
|
||||
return nil, status.Error(codes.Internal, "failed processing input")
|
||||
return nil, status.Error(codes.Internal, "failed to clone input ticket proto")
|
||||
}
|
||||
|
||||
ticket.Id = xid.New().String()
|
||||
err := store.CreateTicket(ctx, ticket)
|
||||
if err != nil {
|
||||
logger.WithFields(logrus.Fields{
|
||||
frontendServiceLogger.WithFields(logrus.Fields{
|
||||
"error": err.Error(),
|
||||
"ticket": ticket,
|
||||
}).Error("failed to create the ticket")
|
||||
@ -75,7 +73,7 @@ func doCreateTicket(ctx context.Context, req *pb.CreateTicketRequest, store stat
|
||||
|
||||
err = store.IndexTicket(ctx, ticket)
|
||||
if err != nil {
|
||||
logger.WithFields(logrus.Fields{
|
||||
frontendServiceLogger.WithFields(logrus.Fields{
|
||||
"error": err.Error(),
|
||||
"ticket": ticket,
|
||||
}).Error("failed to index the ticket")
|
||||
@ -99,7 +97,7 @@ func doDeleteTicket(ctx context.Context, id string, store statestore.Service) er
|
||||
// Deindex this Ticket to remove it from matchmaking pool.
|
||||
err := store.DeindexTicket(ctx, id)
|
||||
if err != nil {
|
||||
logger.WithFields(logrus.Fields{
|
||||
frontendServiceLogger.WithFields(logrus.Fields{
|
||||
"error": err.Error(),
|
||||
"id": id,
|
||||
}).Error("failed to deindex the ticket")
|
||||
@ -111,7 +109,7 @@ func doDeleteTicket(ctx context.Context, id string, store statestore.Service) er
|
||||
go func() {
|
||||
err := store.DeleteTicket(context.Background(), id)
|
||||
if err != nil {
|
||||
logger.WithFields(logrus.Fields{
|
||||
frontendServiceLogger.WithFields(logrus.Fields{
|
||||
"error": err.Error(),
|
||||
"id": id,
|
||||
}).Error("failed to delete the ticket")
|
||||
@ -131,7 +129,7 @@ func (s *frontendService) GetTicket(ctx context.Context, req *pb.GetTicketReques
|
||||
func doGetTickets(ctx context.Context, id string, store statestore.Service) (*pb.Ticket, error) {
|
||||
ticket, err := store.GetTicket(ctx, id)
|
||||
if err != nil {
|
||||
logger.WithFields(logrus.Fields{
|
||||
frontendServiceLogger.WithFields(logrus.Fields{
|
||||
"error": err.Error(),
|
||||
"id": id,
|
||||
}).Error("failed to get the ticket")
|
||||
@ -168,13 +166,12 @@ func doGetAssignments(ctx context.Context, id string, sender func(*pb.Assignment
|
||||
!cmp.Equal(currAssignment.GetError(), assignment.GetError()) {
|
||||
currAssignment, ok = proto.Clone(assignment).(*pb.Assignment)
|
||||
if !ok {
|
||||
logger.Error("failed to cast assignment object")
|
||||
return status.Error(codes.Internal, "failed to cast the assignment object")
|
||||
}
|
||||
|
||||
err := sender(currAssignment)
|
||||
if err != nil {
|
||||
logger.WithError(err).Error("failed to send Redis response to grpc server")
|
||||
frontendServiceLogger.WithError(err).Error("failed to send Redis response to grpc server")
|
||||
return status.Errorf(codes.Aborted, err.Error())
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
logger = logrus.WithFields(logrus.Fields{
|
||||
mmlogicServiceLogger = logrus.WithFields(logrus.Fields{
|
||||
"app": "openmatch",
|
||||
"component": "app.mmlogic.mmlogic_service",
|
||||
})
|
||||
@ -44,7 +44,7 @@ type mmlogicService struct {
|
||||
// specified Pool.
|
||||
func (s *mmlogicService) QueryTickets(req *pb.QueryTicketsRequest, responseServer pb.MmLogic_QueryTicketsServer) error {
|
||||
if req.GetPool() == nil {
|
||||
return status.Error(codes.InvalidArgument, "pool is empty")
|
||||
return status.Error(codes.InvalidArgument, ".pool is required")
|
||||
}
|
||||
|
||||
ctx := responseServer.Context()
|
||||
@ -54,7 +54,7 @@ func (s *mmlogicService) QueryTickets(req *pb.QueryTicketsRequest, responseServe
|
||||
callback := func(tickets []*pb.Ticket) error {
|
||||
err := responseServer.Send(&pb.QueryTicketsResponse{Ticket: tickets})
|
||||
if err != nil {
|
||||
logger.WithError(err).Error("Failed to send Redis response to grpc server")
|
||||
mmlogicServiceLogger.WithError(err).Error("Failed to send Redis response to grpc server")
|
||||
return status.Errorf(codes.Aborted, err.Error())
|
||||
}
|
||||
return nil
|
||||
@ -69,7 +69,7 @@ func doQueryTickets(ctx context.Context, filters []*pb.Filter, pageSize int, sen
|
||||
err := store.FilterTickets(ctx, filters, pageSize, sender)
|
||||
|
||||
if err != nil {
|
||||
logger.WithError(err).Error("Failed to retrieve result from storage service.")
|
||||
mmlogicServiceLogger.WithError(err).Error("Failed to retrieve result from storage service.")
|
||||
return err
|
||||
}
|
||||
|
||||
@ -96,12 +96,12 @@ func getPageSize(cfg config.View) int {
|
||||
|
||||
pSize := cfg.GetInt("storage.page.size")
|
||||
if pSize < minPageSize {
|
||||
logger.Warningf("page size %v is lower than the minimum limit of %v", pSize, maxPageSize)
|
||||
mmlogicServiceLogger.Infof("page size %v is lower than the minimum limit of %v", pSize, maxPageSize)
|
||||
pSize = minPageSize
|
||||
}
|
||||
|
||||
if pSize > maxPageSize {
|
||||
logger.Warningf("page size %v is higher than the maximum limit of %v", pSize, maxPageSize)
|
||||
mmlogicServiceLogger.Infof("page size %v is higher than the maximum limit of %v", pSize, maxPageSize)
|
||||
return maxPageSize
|
||||
}
|
||||
|
||||
|
@ -24,12 +24,10 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
// Logrus structured logging setup
|
||||
logFields = logrus.Fields{
|
||||
cfgLog = logrus.WithFields(logrus.Fields{
|
||||
"app": "openmatch",
|
||||
"component": "config",
|
||||
}
|
||||
cfgLog = logrus.WithFields(logFields)
|
||||
})
|
||||
|
||||
// Map of the config file keys to environment variable names populated by
|
||||
// k8s into pods. Examples of redis-related env vars as written by k8s
|
||||
|
Reference in New Issue
Block a user