Merge pull request #4906 from payall4u/bugfix/fix-open-shim-fifo

bugfix: change the flag of open log fifo to avoid containerd hang on syscall open
This commit is contained in:
Phil Estes 2021-02-01 09:01:38 -05:00 committed by GitHub
commit 49c5c14879
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 4 deletions

View File

@ -115,6 +115,7 @@ func (b *binary) Start(ctx context.Context, opts *types.Any, onClose func()) (_
onCloseWithShimLog := func() {
onClose()
cancelShimLog()
f.Close()
}
client := ttrpc.NewClient(conn, ttrpc.WithOnClose(onCloseWithShimLog))
return &shim{

View File

@ -76,7 +76,13 @@ func loadShim(ctx context.Context, bundle *Bundle, events *exchange.Exchange, rt
conn.Close()
}
}()
f, err := openShimLog(ctx, bundle, client.AnonReconnectDialer)
shimCtx, cancelShimLog := context.WithCancel(ctx)
defer func() {
if err != nil {
cancelShimLog()
}
}()
f, err := openShimLog(shimCtx, bundle, client.AnonReconnectDialer)
if err != nil {
return nil, errors.Wrap(err, "open shim log pipe")
}
@ -99,8 +105,12 @@ func loadShim(ctx context.Context, bundle *Bundle, events *exchange.Exchange, rt
}
}
}()
client := ttrpc.NewClient(conn, ttrpc.WithOnClose(onClose))
onCloseWithShimLog := func() {
onClose()
cancelShimLog()
f.Close()
}
client := ttrpc.NewClient(conn, ttrpc.WithOnClose(onCloseWithShimLog))
defer func() {
if err != nil {
client.Close()

View File

@ -30,7 +30,7 @@ import (
)
func openShimLog(ctx context.Context, bundle *Bundle, _ func(string, time.Duration) (net.Conn, error)) (io.ReadCloser, error) {
return fifo.OpenFifo(ctx, filepath.Join(bundle.Path, "log"), unix.O_RDONLY|unix.O_CREAT|unix.O_NONBLOCK, 0700)
return fifo.OpenFifo(ctx, filepath.Join(bundle.Path, "log"), unix.O_RDWR|unix.O_CREAT|unix.O_NONBLOCK, 0700)
}
func checkCopyShimLogError(ctx context.Context, err error) error {