From b294f6353a4cd61fb66e2ee7d0ebb754e6fcfdf5 Mon Sep 17 00:00:00 2001 From: Mahmood Ali Date: Tue, 25 May 2021 14:24:24 -0400 Subject: [PATCH] add a note about node connection failure and fallback --- api/allocations_exec.go | 7 ++++++- vendor/github.com/hashicorp/nomad/api/allocations_exec.go | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/api/allocations_exec.go b/api/allocations_exec.go index ea34b2450..9f5e0e299 100644 --- a/api/allocations_exec.go +++ b/api/allocations_exec.go @@ -62,7 +62,12 @@ func (s *execSession) run(ctx context.Context) (exitCode int, err error) { } func (s *execSession) startConnection() (*websocket.Conn, error) { - nodeClient, _ := s.client.GetNodeClientWithTimeout(s.alloc.NodeID, ClientConnTimeout, s.q) + // First, attempt to connect to the node directly, but may fail due to network isolation + // and network errors. Fallback to using server-side forwarding instead. + nodeClient, err := s.client.GetNodeClientWithTimeout(s.alloc.NodeID, ClientConnTimeout, s.q) + if err == NodeDownErr { + return nil, NodeDownErr + } q := s.q if q == nil { diff --git a/vendor/github.com/hashicorp/nomad/api/allocations_exec.go b/vendor/github.com/hashicorp/nomad/api/allocations_exec.go index ea34b2450..9f5e0e299 100644 --- a/vendor/github.com/hashicorp/nomad/api/allocations_exec.go +++ b/vendor/github.com/hashicorp/nomad/api/allocations_exec.go @@ -62,7 +62,12 @@ func (s *execSession) run(ctx context.Context) (exitCode int, err error) { } func (s *execSession) startConnection() (*websocket.Conn, error) { - nodeClient, _ := s.client.GetNodeClientWithTimeout(s.alloc.NodeID, ClientConnTimeout, s.q) + // First, attempt to connect to the node directly, but may fail due to network isolation + // and network errors. Fallback to using server-side forwarding instead. + nodeClient, err := s.client.GetNodeClientWithTimeout(s.alloc.NodeID, ClientConnTimeout, s.q) + if err == NodeDownErr { + return nil, NodeDownErr + } q := s.q if q == nil {