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 15, 2024
1 parent 77e4bfd commit 9adbcfd
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,10 @@ func (s *server) probeOperatorPorts(ctx context.Context, operatorId string) (*Op
dispersalSocket := operatorSocket.GetDispersalSocket()
dispersalOnline := checkIsOperatorOnline(dispersalSocket, 3, s.logger)

if dispersalOnline == true {

Check failure on line 186 in disperser/dataapi/queried_operators_handlers.go

View workflow job for this annotation

GitHub Actions / Linter

S1002: should omit comparison to bool constant, can be simplified to `dispersalOnline` (gosimple)
getNodeInfo(dispersalSocket, operatorId, s.logger)
}

// Create the metadata regardless of online status
portCheckResponse := &OperatorPortCheckResponse{
OperatorId: operatorId,
Expand All @@ -199,12 +204,22 @@ 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)
return

Check failure on line 222 in disperser/dataapi/queried_operators_handlers.go

View workflow job for this annotation

GitHub Actions / Linter

S1023: redundant `return` statement (gosimple)
}

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

0 comments on commit 9adbcfd

Please sign in to comment.