runtime/v2: add comment for checkCopyShimLogError

After #4906, containerd opens fifo in read/write mode in linux platform
The original comment doesn't correct and is removed by #5174.

```
// original comment

// When using a multi-container shim, the fifo of the 2nd to Nth
// container will not be opened when the ctx is done. This will
// cause an ErrReadClosed that can be ignored.
```

However, we should add comment for checkCopyShimLogError to mention why
we call checkCopyShimLogError. The checkCopyShimLogError, it is to prevent
the flood of expected error messages after task die and the expected
errors depend on platform.

Signed-off-by: Wei Fu <fuweid89@gmail.com>
This commit is contained in:
Wei Fu 2021-03-18 12:43:31 +08:00
parent 32a08f1a6a
commit 9fdc96c095
2 changed files with 6 additions and 0 deletions

View File

@ -98,6 +98,9 @@ func (b *binary) Start(ctx context.Context, opts *types.Any, onClose func()) (_
go func() { go func() {
defer f.Close() defer f.Close()
_, err := io.Copy(os.Stderr, f) _, err := io.Copy(os.Stderr, f)
// To prevent flood of error messages, the expected error
// should be reset, like os.ErrClosed or os.ErrNotExist, which
// depends on platform.
err = checkCopyShimLogError(ctx, err) err = checkCopyShimLogError(ctx, err)
if err != nil { if err != nil {
log.G(ctx).WithError(err).Error("copy shim log") log.G(ctx).WithError(err).Error("copy shim log")

View File

@ -97,6 +97,9 @@ func loadShim(ctx context.Context, bundle *Bundle, events *exchange.Exchange, rt
go func() { go func() {
defer f.Close() defer f.Close()
_, err := io.Copy(os.Stderr, f) _, err := io.Copy(os.Stderr, f)
// To prevent flood of error messages, the expected error
// should be reset, like os.ErrClosed or os.ErrNotExist, which
// depends on platform.
err = checkCopyShimLogError(ctx, err) err = checkCopyShimLogError(ctx, err)
if err != nil { if err != nil {
log.G(ctx).WithError(err).Error("copy shim log after reload") log.G(ctx).WithError(err).Error("copy shim log after reload")