Merge pull request #2877 from crosbymichael/fifo-timeout
Add timeout and cancel to shim fifo open
This commit is contained in:
		| @@ -209,22 +209,27 @@ func (e *execProcess) start(ctx context.Context) (err error) { | ||||
| 		e.stdin = sc | ||||
| 	} | ||||
| 	var copyWaitGroup sync.WaitGroup | ||||
| 	ctx, cancel := context.WithTimeout(ctx, 30*time.Second) | ||||
| 	if socket != nil { | ||||
| 		console, err := socket.ReceiveMaster() | ||||
| 		if err != nil { | ||||
| 			cancel() | ||||
| 			return errors.Wrap(err, "failed to retrieve console master") | ||||
| 		} | ||||
| 		if e.console, err = e.parent.Platform.CopyConsole(ctx, console, e.stdio.Stdin, e.stdio.Stdout, e.stdio.Stderr, &e.wg, ©WaitGroup); err != nil { | ||||
| 			cancel() | ||||
| 			return errors.Wrap(err, "failed to start console copy") | ||||
| 		} | ||||
| 	} else if !e.stdio.IsNull() { | ||||
| 		if err := copyPipes(ctx, e.io, e.stdio.Stdin, e.stdio.Stdout, e.stdio.Stderr, &e.wg, ©WaitGroup); err != nil { | ||||
| 			cancel() | ||||
| 			return errors.Wrap(err, "failed to start io pipe copy") | ||||
| 		} | ||||
| 	} | ||||
| 	copyWaitGroup.Wait() | ||||
| 	pid, err := runc.ReadPidFile(opts.PidFile) | ||||
| 	if err != nil { | ||||
| 		cancel() | ||||
| 		return errors.Wrap(err, "failed to retrieve OCI runtime exec pid") | ||||
| 	} | ||||
| 	e.pid = pid | ||||
|   | ||||
| @@ -168,18 +168,22 @@ func (p *Init) Create(ctx context.Context, r *CreateConfig) error { | ||||
| 		p.closers = append(p.closers, sc) | ||||
| 	} | ||||
| 	var copyWaitGroup sync.WaitGroup | ||||
| 	ctx, cancel := context.WithTimeout(ctx, 30*time.Second) | ||||
| 	if socket != nil { | ||||
| 		console, err := socket.ReceiveMaster() | ||||
| 		if err != nil { | ||||
| 			cancel() | ||||
| 			return errors.Wrap(err, "failed to retrieve console master") | ||||
| 		} | ||||
| 		console, err = p.Platform.CopyConsole(ctx, console, r.Stdin, r.Stdout, r.Stderr, &p.wg, ©WaitGroup) | ||||
| 		if err != nil { | ||||
| 			cancel() | ||||
| 			return errors.Wrap(err, "failed to start console copy") | ||||
| 		} | ||||
| 		p.console = console | ||||
| 	} else if !hasNoIO(r) { | ||||
| 		if err := copyPipes(ctx, p.io, r.Stdin, r.Stdout, r.Stderr, &p.wg, ©WaitGroup); err != nil { | ||||
| 			cancel() | ||||
| 			return errors.Wrap(err, "failed to start io pipe copy") | ||||
| 		} | ||||
| 	} | ||||
| @@ -187,6 +191,7 @@ func (p *Init) Create(ctx context.Context, r *CreateConfig) error { | ||||
| 	copyWaitGroup.Wait() | ||||
| 	pid, err := runc.ReadPidFile(pidFile) | ||||
| 	if err != nil { | ||||
| 		cancel() | ||||
| 		return errors.Wrap(err, "failed to retrieve OCI runtime container pid") | ||||
| 	} | ||||
| 	p.pid = pid | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Michael Crosby
					Michael Crosby