Skip to content

Commit

Permalink
Debug log for detached stdin is clearer
Browse files Browse the repository at this point in the history
Fixes #1
  • Loading branch information
itzg committed Sep 21, 2019
1 parent 8734158 commit 44ea5cb
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions stdin_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package entrypoint_demoter

import (
"context"
"errors"
log "github.com/sirupsen/logrus"
"io"
"os"
Expand Down Expand Up @@ -39,8 +40,13 @@ func (h *StdinHandler) Handle(ctx context.Context, stdinPipe io.Writer) {
buf := make([]byte, 1024)
n, err := os.Stdin.Read(buf)
if err != nil {
// container's don't usually have input opened, so just a debug if this fails
log.WithError(err).Debug("failed to read stdin")
if errors.Is(err, io.EOF) {
// container's don't usually have input opened, so just a debug if this fails
log.Debug("stdin is detached, so forwarding is disabled")
} else {
log.WithError(err).Warn("failed to read stdin")
}

return
}
h.stdinMux <- buf[:n]
Expand Down

0 comments on commit 44ea5cb

Please sign in to comment.