Merge pull request #23233 from cgwalters/doc-goroutine-leak

containers/attach: Note bug around goroutine leak
This commit is contained in:
openshift-merge-bot[bot] 2024-07-09 20:36:43 +00:00 committed by GitHub
commit 345bac6716
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 1 deletions

View File

@ -29,7 +29,13 @@ type CloseWriter interface {
CloseWrite() error
}
// Attach attaches to a running container
// Attach attaches to a running container.
//
// NOTE: When stdin is provided, this function currently leaks a goroutine reading from that stream
// even if the ctx is cancelled. The goroutine will only exit if the input stream is closed. For example,
// if stdin is `os.Stdin` attached to a tty, the goroutine will consume a chunk of user input from the
// terminal even after the container has exited. In this scenario the os.Stdin stream will not be expected
// to be closed.
func Attach(ctx context.Context, nameOrID string, stdin io.Reader, stdout io.Writer, stderr io.Writer, attachReady chan bool, options *AttachOptions) error {
if options == nil {
options = new(AttachOptions)