Skip to content

Commit

Permalink
Ensure HealthCheckIP is set for remote connections in Gateway
Browse files Browse the repository at this point in the history
We've seen sporadic failures for the "Gateway status reporting" E2E test
where the endpoint HealthCheckIP isn't set, specifically when globalnet
is enabled. This is b/c globalnet sets the HealthCheckIP sometime later
but the cable driver(s) don't process updates to the remote endpoint's
HealthCheckIP (the gateway syncer gets the endpoint info from the cable
engine). The health checker does process HealthCheckIP updates so adjust
the gateway syncer to set the HealthCheckIP from the LatencyInfo.

Signed-off-by: Tom Pantelis <tompantelis@gmail.com>
  • Loading branch information
tpantelis committed Jun 3, 2024
1 parent bd97a7b commit 049728e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/cableengine/healthchecker/healthchecker.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
type LatencyInfo struct {
ConnectionError string
ConnectionStatus ConnectionStatus
IP string
Spec *submarinerv1.LatencyRTTSpec
}

Expand Down
1 change: 1 addition & 0 deletions pkg/cableengine/healthchecker/pinger.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ func (p *pingerInfo) GetLatencyInfo() *LatencyInfo {
defer p.Unlock()

return &LatencyInfo{
IP: p.ip,
ConnectionStatus: p.connectionStatus,
ConnectionError: p.failureMsg,
Spec: &submarinerv1.LatencyRTTSpec{
Expand Down
2 changes: 2 additions & 0 deletions pkg/cableengine/syncer/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,8 @@ func (gs *GatewaySyncer) generateGatewayObject() *v1.Gateway {
latencyInfo := gs.healthCheck.GetLatencyInfo(&connection.Endpoint)
if latencyInfo != nil {
connection.LatencyRTT = latencyInfo.Spec
connection.Endpoint.HealthCheckIP = latencyInfo.IP

if connection.Status == v1.Connected {
lastRTT, _ := time.ParseDuration(latencyInfo.Spec.Last)
cable.RecordConnectionLatency(localEndpoint.Spec.Backend, &localEndpoint.Spec, &connection.Endpoint, lastRTT.Seconds())
Expand Down
4 changes: 4 additions & 0 deletions pkg/cableengine/syncer/syncer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,7 @@ func testGatewayLatencyInfo() {
}

t.engine.Connections = []submarinerv1.Connection{t.expectedGateway.Status.Connections[0]}
t.engine.Connections[0].Endpoint.HealthCheckIP = ""

t.expectedGateway.Status.Connections[0].LatencyRTT = &submarinerv1.LatencyRTTSpec{
Last: "93ms",
Expand All @@ -415,6 +416,7 @@ func testGatewayLatencyInfo() {
}

t.pinger.SetLatencyInfo(&healthchecker.LatencyInfo{
IP: t.pinger.GetIP(),
ConnectionStatus: healthchecker.Connected,
Spec: t.expectedGateway.Status.Connections[0].LatencyRTT,
})
Expand All @@ -427,6 +429,7 @@ func testGatewayLatencyInfo() {
t.expectedGateway.Status.Connections[0].StatusMessage = "Ping failed"

t.pinger.SetLatencyInfo(&healthchecker.LatencyInfo{
IP: t.pinger.GetIP(),
ConnectionStatus: healthchecker.ConnectionError,
ConnectionError: t.expectedGateway.Status.Connections[0].StatusMessage,
Spec: t.expectedGateway.Status.Connections[0].LatencyRTT,
Expand All @@ -438,6 +441,7 @@ func testGatewayLatencyInfo() {
t.expectedGateway.Status.Connections[0].StatusMessage = ""

t.pinger.SetLatencyInfo(&healthchecker.LatencyInfo{
IP: t.pinger.GetIP(),
ConnectionStatus: healthchecker.Connected,
Spec: t.expectedGateway.Status.Connections[0].LatencyRTT,
})
Expand Down

0 comments on commit 049728e

Please sign in to comment.