@@ -104,12 +104,16 @@ func (cs *CommandService) UpdateDataPlaneStatus(
104104 cs .subscribeClientMutex .Unlock ()
105105 return nil , errors .New ("command service client is not initialized" )
106106 }
107- response , updateError := cs .commandServiceClient .UpdateDataPlaneStatus (ctx , request )
107+
108+ grpcCtx , cancel := context .WithTimeout (ctx , cs .agentConfig .Client .Grpc .ResponseTimeout )
109+ defer cancel ()
110+
111+ response , updateError := cs .commandServiceClient .UpdateDataPlaneStatus (grpcCtx , request )
108112 cs .subscribeClientMutex .Unlock ()
109113
110114 validatedError := grpc .ValidateGrpcError (updateError )
111115 if validatedError != nil {
112- slog .ErrorContext (ctx , "Failed to send update data plane status" , "error" , validatedError )
116+ slog .ErrorContext (grpcCtx , "Failed to send update data plane status" , "error" , validatedError )
113117
114118 return nil , validatedError
115119 }
@@ -384,13 +388,16 @@ func (cs *CommandService) dataPlaneHealthCallback(
384388 return nil , errors .New ("command service client is not initialized" )
385389 }
386390
387- response , updateError := cs .commandServiceClient .UpdateDataPlaneHealth (ctx , request )
391+ grpcCtx , cancel := context .WithTimeout (ctx , cs .agentConfig .Client .Grpc .ResponseTimeout )
392+ defer cancel ()
393+
394+ response , updateError := cs .commandServiceClient .UpdateDataPlaneHealth (grpcCtx , request )
388395 cs .subscribeClientMutex .Unlock ()
389396
390397 validatedError := grpc .ValidateGrpcError (updateError )
391398
392399 if validatedError != nil {
393- slog .ErrorContext (ctx , "Failed to send update data plane health" , "error" , validatedError )
400+ slog .ErrorContext (grpcCtx , "Failed to send update data plane health" , "error" , validatedError )
394401
395402 return nil , validatedError
396403 }
@@ -558,13 +565,16 @@ func (cs *CommandService) connectCallback(
558565 request * mpi.CreateConnectionRequest ,
559566) func () (* mpi.CreateConnectionResponse , error ) {
560567 return func () (* mpi.CreateConnectionResponse , error ) {
568+ grpcCtx , cancel := context .WithTimeout (ctx , cs .agentConfig .Client .Grpc .ResponseTimeout )
569+ defer cancel ()
570+
561571 cs .subscribeClientMutex .Lock ()
562- response , connectErr := cs .commandServiceClient .CreateConnection (ctx , request )
572+ response , connectErr := cs .commandServiceClient .CreateConnection (grpcCtx , request )
563573 cs .subscribeClientMutex .Unlock ()
564574
565575 validatedError := grpc .ValidateGrpcError (connectErr )
566576 if validatedError != nil {
567- slog .ErrorContext (ctx , "Failed to create connection" , "error" , validatedError )
577+ slog .ErrorContext (grpcCtx , "Failed to create connection" , "error" , validatedError )
568578
569579 return nil , validatedError
570580 }
0 commit comments