Skip to content

Commit a591d3f

Browse files
committed
PR feedback
1 parent 5d12025 commit a591d3f

File tree

3 files changed

+7
-18
lines changed

3 files changed

+7
-18
lines changed

internal/file/file_service_operator.go

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,7 @@ func (fso *FileServiceOperator) File(
7979
defer backoffCancel()
8080

8181
getFile := func() (*mpi.GetFileResponse, error) {
82-
grpcCtx, cancel := context.WithTimeout(ctx, fso.agentConfig.Client.Grpc.ResponseTimeout)
83-
defer cancel()
84-
85-
return fso.fileServiceClient.GetFile(grpcCtx, &mpi.GetFileRequest{
82+
return fso.fileServiceClient.GetFile(ctx, &mpi.GetFileRequest{
8683
MessageMeta: &mpi.MessageMeta{
8784
MessageId: id.GenerateMessageID(),
8885
CorrelationId: logger.CorrelationID(ctx),
@@ -231,10 +228,7 @@ func (fso *FileServiceOperator) ChunkedFile(
231228
) error {
232229
slog.DebugContext(ctx, "Getting chunked file", "file", file.GetFileMeta().GetName())
233230

234-
grpcCtx, cancel := context.WithTimeout(ctx, fso.agentConfig.Client.Grpc.ResponseTimeout)
235-
defer cancel()
236-
237-
stream, err := fso.fileServiceClient.GetFileStream(grpcCtx, &mpi.GetFileRequest{
231+
stream, err := fso.fileServiceClient.GetFileStream(ctx, &mpi.GetFileRequest{
238232
MessageMeta: &mpi.MessageMeta{
239233
MessageId: id.GenerateMessageID(),
240234
CorrelationId: logger.CorrelationID(ctx),
@@ -380,15 +374,12 @@ func (fso *FileServiceOperator) sendUpdateFileRequest(
380374
return nil, errors.New("CreateConnection rpc has not being called yet")
381375
}
382376

383-
grpcCtx, cancel := context.WithTimeout(ctx, fso.agentConfig.Client.Grpc.ResponseTimeout)
384-
defer cancel()
385-
386-
response, updateError := fso.fileServiceClient.UpdateFile(grpcCtx, request)
377+
response, updateError := fso.fileServiceClient.UpdateFile(ctx, request)
387378

388379
validatedError := internalgrpc.ValidateGrpcError(updateError)
389380

390381
if validatedError != nil {
391-
slog.ErrorContext(grpcCtx, "Failed to send update file", "error", validatedError)
382+
slog.ErrorContext(ctx, "Failed to send update file", "error", validatedError)
392383

393384
return nil, validatedError
394385
}
@@ -418,10 +409,7 @@ func (fso *FileServiceOperator) sendUpdateFileStream(
418409
return errors.New("file chunk size must be greater than zero")
419410
}
420411

421-
grpcCtx, cancel := context.WithTimeout(ctx, fso.agentConfig.Client.Grpc.ResponseTimeout)
422-
defer cancel()
423-
424-
updateFileStreamClient, err := fso.fileServiceClient.UpdateFileStream(grpcCtx)
412+
updateFileStreamClient, err := fso.fileServiceClient.UpdateFileStream(ctx)
425413
if err != nil {
426414
return err
427415
}

nginx-agent.conf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ allowed_directories:
1717
- /usr/share/nginx/modules
1818
- /var/run/nginx
1919
- /var/log/nginx
20-
- /etc/test
2120

2221
#
2322
# Command server settings to connect to a management plane server

test/mock/grpc/mock_management_command_service.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ func (cs *CommandService) CreateConnection(
113113
) {
114114
slog.DebugContext(ctx, "Create connection request", "request", request)
115115

116+
// This checks if this is the first create connection call, this is done to test the logic in Agent where
117+
// if Agent does not get a response to a request after a certain amount of time it will resend the request
116118
if !cs.firstConnectionCallFlag {
117119
cs.firstConnectionCallFlag = true
118120
slog.DebugContext(ctx, "First CreateConnection call: blocking until second call")

0 commit comments

Comments
 (0)