Skip to content

Commit

Permalink
Add v2 dispersal port reachability check
Browse files Browse the repository at this point in the history
```
  "operator_id": "feba99a1e3230e2383f5417ded9695f170491eb4bc2e21110d73f7f127e3d835",
  "dispersal_socket": "23.93.87.156:32005",
  "dispersal_online": true,
  "dispersal_status": "node.Dispersal is available",
  "retrieval_socket": "23.93.87.156:32004",
  "retrieval_online": true,
  "retrieval_status": "node.Retrieval is available",
  "v2_dispersal_socket": "",
  "v2_dispersal_online": false,
  "v2_dispersal_status": "v2 dispersal port is not registered"
}
```

```
  "operator_id": "feba99a1e3230e2383f5417ded9695f170491eb4bc2e21110d73f7f127e3d835",
  "dispersal_socket": "23.93.87.156:32005",
  "dispersal_online": true,
  "dispersal_status": "node.Dispersal is available",
  "retrieval_socket": "23.93.87.156:32004",
  "retrieval_online": true,
  "retrieval_status": "node.Retrieval is available",
  "v2_dispersal_socket": "23.93.87.156:32006",
  "v2_dispersal_online": true,
  "v2_dispersal_status": "node.v2.Dispersal is available"
}
```
  • Loading branch information
pschork committed Jan 22, 2025
1 parent a6b3154 commit ac35574
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 20 deletions.
8 changes: 8 additions & 0 deletions core/serialization.go
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,14 @@ func (s OperatorSocket) GetV1DispersalSocket() string {
return fmt.Sprintf("%s:%s", ip, v1DispersalPort)
}

func (s OperatorSocket) GetV2DispersalSocket() string {
ip, _, _, v2DispersalPort, err := ParseOperatorSocket(string(s))
if err != nil || v2DispersalPort == "" {
return ""
}
return fmt.Sprintf("%s:%s", ip, v2DispersalPort)
}

func (s OperatorSocket) GetRetrievalSocket() string {
ip, _, retrievalPort, _, err := ParseOperatorSocket(string(s))
if err != nil {
Expand Down
42 changes: 29 additions & 13 deletions disperser/dataapi/operator_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,27 +48,43 @@ func (oh *OperatorHandler) ProbeOperatorHosts(ctx context.Context, operatorId st
operatorSocket := core.OperatorSocket(operatorInfo.Socket)
retrievalSocket := operatorSocket.GetRetrievalSocket()
retrievalPortOpen := checkIsOperatorPortOpen(retrievalSocket, 3, oh.logger)
retrievalOnline, retrievalStatus := false, fmt.Sprintf("port closed or unreachable for %s", retrievalSocket)
retrievalOnline, retrievalStatus := false, fmt.Sprintf("port closed or unreachable")

Check failure on line 51 in disperser/dataapi/operator_handler.go

View workflow job for this annotation

GitHub Actions / Linter

S1039: unnecessary use of fmt.Sprintf (gosimple)

Check failure on line 51 in disperser/dataapi/operator_handler.go

View workflow job for this annotation

GitHub Actions / Linter

S1039: unnecessary use of fmt.Sprintf (gosimple)
if retrievalPortOpen {
retrievalOnline, retrievalStatus = checkServiceOnline(ctx, "node.Retrieval", retrievalSocket, 3*time.Second)
}

dispersalSocket := operatorSocket.GetV1DispersalSocket()
dispersalPortOpen := checkIsOperatorPortOpen(dispersalSocket, 3, oh.logger)
dispersalOnline, dispersalStatus := false, fmt.Sprintf("port closed or unreachable for %s", dispersalSocket)
if dispersalPortOpen {
dispersalOnline, dispersalStatus = checkServiceOnline(ctx, "node.Dispersal", dispersalSocket, 3*time.Second)
v1DispersalSocket := operatorSocket.GetV1DispersalSocket()
v1DispersalPortOpen := checkIsOperatorPortOpen(v1DispersalSocket, 3, oh.logger)
v1DispersalOnline, v1DispersalStatus := false, fmt.Sprintf("port closed or unreachable")

Check failure on line 58 in disperser/dataapi/operator_handler.go

View workflow job for this annotation

GitHub Actions / Linter

S1039: unnecessary use of fmt.Sprintf (gosimple)

Check failure on line 58 in disperser/dataapi/operator_handler.go

View workflow job for this annotation

GitHub Actions / Linter

S1039: unnecessary use of fmt.Sprintf (gosimple)
if v1DispersalPortOpen {
v1DispersalOnline, v1DispersalStatus = checkServiceOnline(ctx, "node.Dispersal", v1DispersalSocket, 3*time.Second)
}

v2DispersalOnline, v2DispersalStatus := false, ""
v2DispersalSocket := operatorSocket.GetV2DispersalSocket()
if v2DispersalSocket == "" {
v2DispersalStatus = "v2 dispersal port is not registered"
} else {
v2DispersalPortOpen := checkIsOperatorPortOpen(v2DispersalSocket, 3, oh.logger)
if !v2DispersalPortOpen {
v2DispersalStatus = fmt.Sprintf("port closed or unreachable")

Check failure on line 70 in disperser/dataapi/operator_handler.go

View workflow job for this annotation

GitHub Actions / Linter

S1039: unnecessary use of fmt.Sprintf (gosimple)

Check failure on line 70 in disperser/dataapi/operator_handler.go

View workflow job for this annotation

GitHub Actions / Linter

S1039: unnecessary use of fmt.Sprintf (gosimple)
} else {
v2DispersalOnline, v2DispersalStatus = checkServiceOnline(ctx, "node.v2.Dispersal", v2DispersalSocket, 3*time.Second)
}
}

// Create the metadata regardless of online status
portCheckResponse := &OperatorPortCheckResponse{
OperatorId: operatorId,
DispersalSocket: dispersalSocket,
RetrievalSocket: retrievalSocket,
DispersalOnline: dispersalOnline,
RetrievalOnline: retrievalOnline,
DispersalStatus: dispersalStatus,
RetrievalStatus: retrievalStatus,
OperatorId: operatorId,
DispersalSocket: v1DispersalSocket,
DispersalStatus: v1DispersalStatus,
DispersalOnline: v1DispersalOnline,
V2DispersalSocket: v2DispersalSocket,
V2DispersalOnline: v2DispersalOnline,
V2DispersalStatus: v2DispersalStatus,
RetrievalSocket: retrievalSocket,
RetrievalOnline: retrievalOnline,
RetrievalStatus: retrievalStatus,
}

// Log the online status
Expand Down
17 changes: 10 additions & 7 deletions disperser/dataapi/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,16 @@ type (
}

OperatorPortCheckResponse struct {
OperatorId string `json:"operator_id"`
DispersalSocket string `json:"dispersal_socket"`
RetrievalSocket string `json:"retrieval_socket"`
DispersalOnline bool `json:"dispersal_online"`
RetrievalOnline bool `json:"retrieval_online"`
DispersalStatus string `json:"dispersal_status"`
RetrievalStatus string `json:"retrieval_status"`
OperatorId string `json:"operator_id"`
DispersalSocket string `json:"dispersal_socket"`
DispersalOnline bool `json:"dispersal_online"`
DispersalStatus string `json:"dispersal_status"`
RetrievalSocket string `json:"retrieval_socket"`
RetrievalOnline bool `json:"retrieval_online"`
RetrievalStatus string `json:"retrieval_status"`
V2DispersalSocket string `json:"v2_dispersal_socket"`
V2DispersalOnline bool `json:"v2_dispersal_online"`
V2DispersalStatus string `json:"v2_dispersal_status"`
}
SemverReportResponse struct {
Semver map[string]*semver.SemverMetrics `json:"semver"`
Expand Down

0 comments on commit ac35574

Please sign in to comment.