From 49b788dc9a575492512341bbd90e18a2bbff2b60 Mon Sep 17 00:00:00 2001 From: Maru Newby Date: Tue, 1 Oct 2024 11:45:00 -0700 Subject: [PATCH] fixup: Respond to review feedback --- .../fixture/bootstrapmonitor/e2e/e2e_test.go | 1 - tests/fixture/tmpnet/utils.go | 21 ++++++++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/tests/fixture/bootstrapmonitor/e2e/e2e_test.go b/tests/fixture/bootstrapmonitor/e2e/e2e_test.go index 0ee0ffe9b877..9ea89105438e 100644 --- a/tests/fixture/bootstrapmonitor/e2e/e2e_test.go +++ b/tests/fixture/bootstrapmonitor/e2e/e2e_test.go @@ -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) diff --git a/tests/fixture/tmpnet/utils.go b/tests/fixture/tmpnet/utils.go index f2613f462208..1ed097c864ac 100644 --- a/tests/fixture/tmpnet/utils.go +++ b/tests/fixture/tmpnet/utils.go @@ -6,6 +6,7 @@ package tmpnet import ( "context" "encoding/json" + "errors" "fmt" "net" "syscall" @@ -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) @@ -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. @@ -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 }