Skip to content

Commit

Permalink
Reuse upstream context
Browse files Browse the repository at this point in the history
  • Loading branch information
pschork committed Jul 17, 2024
1 parent 0a27be1 commit 0d02764
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions disperser/dataapi/queried_operators_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ func (s *server) probeOperatorPorts(ctx context.Context, operatorId string) (*Op

if dispersalOnline {
// collect node info if online
getNodeInfo(dispersalSocket, operatorId, 3, s.logger)
getNodeInfo(ctx, dispersalSocket, operatorId, s.logger)
}

// Create the metadata regardless of online status
Expand All @@ -205,16 +205,14 @@ func (s *server) probeOperatorPorts(ctx context.Context, operatorId string) (*Op
}

// query operator host info endpoint if available
func getNodeInfo(socket string, operatorId string, timeoutSecs int, logger logging.Logger) {
func getNodeInfo(ctx context.Context, socket string, operatorId string, logger logging.Logger) {
conn, err := grpc.Dial(socket, grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil {
logger.Error("Failed to dial grpc operator socket", "operatorId", operatorId, "socket", socket, "error", err)
return
}
defer conn.Close()
client := node.NewDispersalClient(conn)
ctx, cancel := context.WithTimeout(context.Background(), time.Duration(timeoutSecs)*time.Second)
defer cancel()
reply, err := client.NodeInfo(ctx, &node.NodeInfoRequest{})
if err != nil {
logger.Info("NodeInfo", "operatorId", operatorId, "semver", "unknown")
Expand Down

0 comments on commit 0d02764

Please sign in to comment.