Skip to content

Commit

Permalink
Collect NodeInfo endpoint if port check was successful
Browse files Browse the repository at this point in the history
  • Loading branch information
pschork committed Jul 16, 2024
1 parent 77e4bfd commit d9c30d2
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions disperser/dataapi/queried_operators_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import (
"github.com/Layr-Labs/eigenda/core"
"github.com/Layr-Labs/eigensdk-go/logging"
"github.com/gammazero/workerpool"
"google.golang.org/grpc/health/grpc_health_v1"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
)

type OperatorOnlineStatus struct {
Expand Down Expand Up @@ -182,6 +183,11 @@ func (s *server) probeOperatorPorts(ctx context.Context, operatorId string) (*Op
dispersalSocket := operatorSocket.GetDispersalSocket()
dispersalOnline := checkIsOperatorOnline(dispersalSocket, 3, s.logger)

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

// Create the metadata regardless of online status
portCheckResponse := &OperatorPortCheckResponse{
OperatorId: operatorId,
Expand All @@ -199,12 +205,21 @@ func (s *server) probeOperatorPorts(ctx context.Context, operatorId string) (*Op
}

// query operator host info endpoint if available
func (s *Server) checkNodeInfo(socket string, operatorId string, timeoutSecs int, logger logging.Logger) (*node.NodeInfoReply, error) {
var client node.NodeInfoRequest

client = grpc_health_v1.NewHealthClient(s.disperserConn)
func getNodeInfo(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)
reply, err := client.NodeInfo(context.Background(), &node.NodeInfoRequest{})
if err != nil {
logger.Info("NodeInfo", "operatorId", operatorId, "semver", "unknown")
return
}

return client.Check(ctx, &node.NodeInfoReply{})
logger.Info("NodeInfo", "operatorId", operatorId, "semver", reply.Semver, "os", reply.Os, "arch", reply.Arch, "numCpu", reply.NumCpu, "memBytes", reply.MemBytes)
}

// method to check if operator is online via socket dial
Expand Down

0 comments on commit d9c30d2

Please sign in to comment.