only warn on resize errors
prevent resize from blocking exit fix edgecase where kill signal never reaches process Signed-off-by: Cory Bennett <cbennett@netflix.com>v0.8
parent
f781f83a89
commit
86e246a874
|
@ -2,6 +2,7 @@ package containerdexecutor
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -318,6 +319,7 @@ func (w *containerdExecutor) runProcess(ctx context.Context, p containerd.Proces
|
||||||
p.CloseIO(ctx, containerd.WithStdinCloser)
|
p.CloseIO(ctx, containerd.WithStdinCloser)
|
||||||
|
|
||||||
var cancel func()
|
var cancel func()
|
||||||
|
var killCtxDone <-chan struct{}
|
||||||
ctxDone := ctx.Done()
|
ctxDone := ctx.Done()
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
|
@ -325,13 +327,8 @@ func (w *containerdExecutor) runProcess(ctx context.Context, p containerd.Proces
|
||||||
ctxDone = nil
|
ctxDone = nil
|
||||||
var killCtx context.Context
|
var killCtx context.Context
|
||||||
killCtx, cancel = context.WithTimeout(context.Background(), 10*time.Second)
|
killCtx, cancel = context.WithTimeout(context.Background(), 10*time.Second)
|
||||||
|
killCtxDone = killCtx.Done()
|
||||||
p.Kill(killCtx, syscall.SIGKILL)
|
p.Kill(killCtx, syscall.SIGKILL)
|
||||||
case size := <-resize:
|
|
||||||
err := p.Resize(ctx, size.Cols, size.Rows)
|
|
||||||
if err != nil {
|
|
||||||
cancel()
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
case status := <-statusCh:
|
case status := <-statusCh:
|
||||||
if cancel != nil {
|
if cancel != nil {
|
||||||
cancel()
|
cancel()
|
||||||
|
@ -352,6 +349,20 @@ func (w *containerdExecutor) runProcess(ctx context.Context, p containerd.Proces
|
||||||
return exitErr
|
return exitErr
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
case <-killCtxDone:
|
||||||
|
if cancel != nil {
|
||||||
|
cancel()
|
||||||
|
}
|
||||||
|
return fmt.Errorf("failed to kill process on cancel")
|
||||||
|
case size := <-resize:
|
||||||
|
ctxTimeout, cancelTimeout := context.WithTimeout(ctx, time.Second)
|
||||||
|
go func() {
|
||||||
|
defer cancelTimeout()
|
||||||
|
err = p.Resize(ctxTimeout, size.Cols, size.Rows)
|
||||||
|
if err != nil {
|
||||||
|
logrus.Warnf("Failed to resize %s: %s", p.ID(), err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue