Merge pull request #2551 from crosbymichael/stdin-block

Don't block on STDIN open
This commit is contained in:
Derek McGowan 2018-08-28 10:24:05 -07:00 committed by GitHub
commit ce1161f806
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 5 additions and 12 deletions

View File

@ -164,10 +164,7 @@ func (e *execProcess) start(ctx context.Context) (err error) {
return e.parent.runtimeError(err, "OCI runtime exec failed") return e.parent.runtimeError(err, "OCI runtime exec failed")
} }
if e.stdio.Stdin != "" { if e.stdio.Stdin != "" {
fifoCtx, cancel := context.WithTimeout(ctx, 15*time.Second) sc, err := fifo.OpenFifo(ctx, e.stdio.Stdin, syscall.O_WRONLY|syscall.O_NONBLOCK, 0)
defer cancel()
sc, err := fifo.OpenFifo(fifoCtx, e.stdio.Stdin, syscall.O_WRONLY|syscall.O_NONBLOCK, 0)
if err != nil { if err != nil {
return errors.Wrapf(err, "failed to open stdin fifo %s", e.stdio.Stdin) return errors.Wrapf(err, "failed to open stdin fifo %s", e.stdio.Stdin)
} }
@ -184,10 +181,7 @@ func (e *execProcess) start(ctx context.Context) (err error) {
return errors.Wrap(err, "failed to start console copy") return errors.Wrap(err, "failed to start console copy")
} }
} else if !e.stdio.IsNull() { } else if !e.stdio.IsNull() {
fifoCtx, cancel := context.WithTimeout(ctx, 15*time.Second) if err := copyPipes(ctx, e.io, e.stdio.Stdin, e.stdio.Stdout, e.stdio.Stderr, &e.wg, &copyWaitGroup); err != nil {
defer cancel()
if err := copyPipes(fifoCtx, e.io, e.stdio.Stdin, e.stdio.Stdout, e.stdio.Stderr, &e.wg, &copyWaitGroup); err != nil {
return errors.Wrap(err, "failed to start io pipe copy") return errors.Wrap(err, "failed to start io pipe copy")
} }
} }

View File

@ -112,7 +112,7 @@ func copyPipes(ctx context.Context, rio runc.IO, stdin, stdout, stderr string, w
rio.Stdin().Close() rio.Stdin().Close()
return nil return nil
} }
f, err := fifo.OpenFifo(ctx, stdin, syscall.O_RDONLY, 0) f, err := fifo.OpenFifo(ctx, stdin, syscall.O_RDONLY|syscall.O_NONBLOCK, 0)
if err != nil { if err != nil {
return fmt.Errorf("containerd-shim: opening %s failed: %s", stdin, err) return fmt.Errorf("containerd-shim: opening %s failed: %s", stdin, err)
} }

View File

@ -99,7 +99,6 @@ type service struct {
ep *epoller ep *epoller
id string id string
// Filled by Create()
bundle string bundle string
cg cgroups.Cgroup cg cgroups.Cgroup
} }

View File

@ -42,7 +42,7 @@ func (p *linuxPlatform) CopyConsole(ctx context.Context, console console.Console
} }
if stdin != "" { if stdin != "" {
in, err := fifo.OpenFifo(ctx, stdin, syscall.O_RDONLY, 0) in, err := fifo.OpenFifo(ctx, stdin, syscall.O_RDONLY|syscall.O_NONBLOCK, 0)
if err != nil { if err != nil {
return nil, err return nil, err
} }