agent: surface websocket errors in logs

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.
This commit is contained in:
Tim Gross
2021-05-24 09:46:45 -04:00
committed by GitHub
parent 51073e51c8
commit 4f57e06957

View File

@@ -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 {