Skip to content

Commit

Permalink
fixup: Respond to review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
maru-ava committed Oct 1, 2024
1 parent 7da8fdd commit 49b788d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
1 change: 0 additions & 1 deletion tests/fixture/bootstrapmonitor/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ var _ = ginkgo.Describe("[Bootstrap Tester]", func() {
if !strings.Contains(testConfig.Image, "sha256") {
return false
}

containerImage = testConfig.Image
return true
}, e2e.DefaultTimeout, e2e.DefaultPollingInterval)
Expand Down
21 changes: 14 additions & 7 deletions tests/fixture/tmpnet/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package tmpnet
import (
"context"
"encoding/json"
"errors"
"fmt"
"net"
"syscall"
Expand All @@ -20,6 +21,8 @@ const (
DefaultNodeTickerInterval = 50 * time.Millisecond
)

var ErrUnrecoverableNodeHealthCheck = errors.New("failed to query node health")

func CheckNodeHealth(ctx context.Context, uri string) (*health.APIReply, error) {
// Check that the node is reporting healthy
healthReply, err := health.NewClient(uri).Health(ctx, nil)
Expand All @@ -31,16 +34,16 @@ func CheckNodeHealth(ctx context.Context, uri string) (*health.APIReply, error)
case *net.OpError:
if t.Op == "read" {
// Connection refused - potentially recoverable
return nil, nil
return nil, err
}
case syscall.Errno:
if t == syscall.ECONNREFUSED {
// Connection refused - potentially recoverable
return nil, nil
return nil, err
}
}
// Assume all other errors are not recoverable
return nil, fmt.Errorf("failed to query node health: %w", err)
return nil, fmt.Errorf("%w: %w", ErrUnrecoverableNodeHealthCheck, err)
}

// WaitForHealthy blocks until Node.IsHealthy returns true or an error (including context timeout) is observed.
Expand All @@ -53,10 +56,14 @@ func WaitForHealthy(ctx context.Context, node *Node) error {

for {
healthy, err := node.IsHealthy(ctx)
if err != nil {
return fmt.Errorf("failed to wait for health of node %q: %w", node.NodeID, err)
}
if healthy {
switch {
case errors.Is(err, ErrUnrecoverableNodeHealthCheck):
return fmt.Errorf("%w for node %q", err, node.NodeID)
case err != nil:
// Error is recoverable
// TODO(marun) Log the error to aid in troubleshooting once a logger is available
continue
case healthy:
return nil
}

Expand Down

0 comments on commit 49b788d

Please # to comment.