Skip to content

Commit

Permalink
Call 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 75ac9d3
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 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,10 @@ func (s *server) probeOperatorPorts(ctx context.Context, operatorId string) (*Op
dispersalSocket := operatorSocket.GetDispersalSocket()
dispersalOnline := checkIsOperatorOnline(dispersalSocket, 3, s.logger)

if dispersalOnline {
getNodeInfo(dispersalSocket, operatorId, s.logger)
}

// Create the metadata regardless of online status
portCheckResponse := &OperatorPortCheckResponse{
OperatorId: operatorId,
Expand All @@ -199,12 +204,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 operator", err)
return
}
defer conn.Close()
client := node.NewDispersalClient(conn)
reply, err := client.NodeInfo(context.Background(), &node.NodeInfoRequest{})
if err != nil {
logger.Error("Failed to call node info api", err)
return
}

return client.Check(ctx, &node.NodeInfoReply{})
logger.Info(operatorId, reply.Semver, reply.Arch, reply.Os, reply.NumCpu, reply.MemBytes)
}

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

0 comments on commit 75ac9d3

Please sign in to comment.