Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collect Node Info during reachability check if port scan was successful #640

Merged
merged 4 commits into from
Jul 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 27 additions & 3 deletions disperser/dataapi/queried_operators_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ import (
"sort"
"time"

"github.com/Layr-Labs/eigenda/api/grpc/node"
"github.com/Layr-Labs/eigenda/core"
"github.com/Layr-Labs/eigensdk-go/logging"
"github.com/gammazero/workerpool"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
)

type OperatorOnlineStatus struct {
Expand Down Expand Up @@ -180,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(ctx, dispersalSocket, operatorId, s.logger)
}

// Create the metadata regardless of online status
portCheckResponse := &OperatorPortCheckResponse{
OperatorId: operatorId,
Expand All @@ -196,9 +204,25 @@ func (s *server) probeOperatorPorts(ctx context.Context, operatorId string) (*Op
return portCheckResponse, nil
}

// method to check if operator is online
// Note: This method is least intrusive way to check if operator is online
// AlternateSolution: Should we add an endpt to check if operator is online?
// query operator host info endpoint if available
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)
reply, err := client.NodeInfo(ctx, &node.NodeInfoRequest{})
if err != nil {
logger.Info("NodeInfo", "operatorId", operatorId, "semver", "unknown")
return
}

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
func checkIsOperatorOnline(socket string, timeoutSecs int, logger logging.Logger) bool {
if !ValidOperatorIP(socket, logger) {
logger.Error("port check blocked invalid operator IP", "socket", socket)
Expand Down
Loading