Skip to content

Commit

Permalink
api: alloc exec recovers from bad client connection
Browse files Browse the repository at this point in the history
If alloc exec fails to connect to the nomad client associated with the
alloc, fail over to using a server.

The code attempted to special case `net.Error` for failover to rule out
other permanent non-networking errors, by reusing a pattern in the
logging handling.

But this pattern does not apply here.  `net/http.Http` wraps all errors
as `*url.Error` that is net.Error.  The websocket doesn't, and instead
returns the raw error.  If the raw error isn't a `net.Error`, like in
the case of TLS handshake errors, the api package would fail immediately
rather than failover.
  • Loading branch information
Mahmood Ali committed Mar 4, 2020
1 parent 34b6342 commit c50f295
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions api/allocations.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"errors"
"fmt"
"io"
"net"
"sort"
"strconv"
"sync"
Expand Down Expand Up @@ -234,11 +233,7 @@ func (a *Allocations) execFrames(ctx context.Context, alloc *Allocation, task st
var conn *websocket.Conn

if nodeClient != nil {
conn, _, err = nodeClient.websocket(reqPath, q)
if _, ok := err.(net.Error); err != nil && !ok {
errCh <- err
return nil, nil
}
conn, _, _ = nodeClient.websocket(reqPath, q)
}

if conn == nil {
Expand Down

0 comments on commit c50f295

Please sign in to comment.