Skip to content

Commit

Permalink
agent: surface websocket errors in logs
Browse files Browse the repository at this point in the history
The websocket interface used for `alloc exec` has to silently drop client send
errors because otherwise those errors would interleave with the streamed
output. But we may be able to surface errors that cause terminated websockets
a little better in the HTTP server logs.
  • Loading branch information
tgross committed May 24, 2021
1 parent 51073e5 commit 4f57e06
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion command/agent/alloc_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -556,10 +556,14 @@ func (s *HTTPServer) execStreamImpl(ws *websocket.Conn, args *cstructs.AllocExec
handler(handlerPipe)
// stop streaming background goroutines for streaming - but not websocket activity
cancel()
// retreieve any error and/or wait until goroutine stop and close errCh connection before
// retrieve any error and/or wait until goroutine stop and close errCh connection before
// closing websocket connection
codedErr := <-errCh

// we won't return an error on ws close, but at least make it available in
// the logs so we can trace spurious disconnects
s.logger.Debug("alloc exec channel closed with error", "error", codedErr)

if isClosedError(codedErr) {
codedErr = nil
} else if codedErr != nil {
Expand Down

0 comments on commit 4f57e06

Please sign in to comment.