Skip to content

Commit c6cea95

Browse files
committed
Make StopPodSandbox RPC idempotent
Similar to sandbox removal, the stop of a sandbox should be a noop if the sandbox has not been found. Found during: kubernetes-sigs/cri-tools#1535 Signed-off-by: Sascha Grunert <[email protected]>
1 parent ea3e1d9 commit c6cea95

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

internal/cri/server/sandbox_stop.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,15 @@ import (
3434
func (c *criService) StopPodSandbox(ctx context.Context, r *runtime.StopPodSandboxRequest) (*runtime.StopPodSandboxResponse, error) {
3535
sandbox, err := c.sandboxStore.Get(r.GetPodSandboxId())
3636
if err != nil {
37-
return nil, fmt.Errorf("an error occurred when try to find sandbox %q: %w",
38-
r.GetPodSandboxId(), err)
37+
if !errdefs.IsNotFound(err) {
38+
return nil, fmt.Errorf("an error occurred when try to find sandbox %q: %w",
39+
r.GetPodSandboxId(), err)
40+
}
41+
42+
// The StopPodSandbox RPC is idempotent, and must not return an error
43+
// if all relevant resources have already been reclaimed. Ref:
44+
// https://github.com/kubernetes/cri-api/blob/c20fa40/pkg/apis/runtime/v1/api.proto#L45-L46
45+
return &runtime.StopPodSandboxResponse{}, nil
3946
}
4047

4148
if err := c.stopPodSandbox(ctx, sandbox); err != nil {

0 commit comments

Comments
 (0)