mirror of
https://github.com/containerd/containerd.git
synced 2026-11-06 05:17:02 +00:00
sandbox: tolerate a shim exiting during ShutdownSandbox
A sandbox shim may exit as soon as it has shut its sandbox down, before containerd reads the ShutdownSandbox response, in which case the client sees ttrpc.ErrClosed. The task Shutdown RPC has the same race and shimTask.Shutdown treats a closed connection as a successful shutdown; controllerLocal.Shutdown returned it as an error instead, failing RemovePodSandbox for a sandbox that was already gone. Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
This commit is contained in:
1 file changed
+6
-1
@@ -18,6 +18,7 @@ package sandbox
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"time"
|
||||
@@ -27,6 +28,7 @@ import (
|
||||
"github.com/containerd/log"
|
||||
"github.com/containerd/plugin"
|
||||
"github.com/containerd/plugin/registry"
|
||||
"github.com/containerd/ttrpc"
|
||||
"github.com/containerd/typeurl/v2"
|
||||
imagespec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
|
||||
@@ -260,8 +262,11 @@ func (c *controllerLocal) Shutdown(ctx context.Context, sandboxID string) error
|
||||
return err
|
||||
}
|
||||
|
||||
// A shim may exit as soon as it has shut its sandbox down, before the
|
||||
// response is read; a closed connection means the shutdown happened, as
|
||||
// for the task Shutdown RPC.
|
||||
_, err = svc.ShutdownSandbox(ctx, &runtimeAPI.ShutdownSandboxRequest{SandboxID: sandboxID})
|
||||
if err != nil {
|
||||
if err != nil && !errors.Is(err, ttrpc.ErrClosed) {
|
||||
return fmt.Errorf("failed to shutdown sandbox: %w", errgrpc.ToNative(err))
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user