File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ import (
2222 "fmt"
2323 "time"
2424
25+ "github.com/containerd/errdefs"
2526 "github.com/containerd/log"
2627 runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
2728
@@ -33,8 +34,15 @@ import (
3334func (c * criService ) StopPodSandbox (ctx context.Context , r * runtime.StopPodSandboxRequest ) (* runtime.StopPodSandboxResponse , error ) {
3435 sandbox , err := c .sandboxStore .Get (r .GetPodSandboxId ())
3536 if err != nil {
36- return nil , fmt .Errorf ("an error occurred when try to find sandbox %q: %w" ,
37- 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
3846 }
3947
4048 if err := c .stopPodSandbox (ctx , sandbox ); err != nil {
Original file line number Diff line number Diff line change @@ -38,8 +38,15 @@ import (
3838func (c * criService ) StopPodSandbox (ctx context.Context , r * runtime.StopPodSandboxRequest ) (* runtime.StopPodSandboxResponse , error ) {
3939 sandbox , err := c .sandboxStore .Get (r .GetPodSandboxId ())
4040 if err != nil {
41- return nil , fmt .Errorf ("an error occurred when try to find sandbox %q: %w" ,
42- r .GetPodSandboxId (), err )
41+ if ! errdefs .IsNotFound (err ) {
42+ return nil , fmt .Errorf ("an error occurred when try to find sandbox %q: %w" ,
43+ r .GetPodSandboxId (), err )
44+ }
45+
46+ // The StopPodSandbox RPC is idempotent, and must not return an error
47+ // if all relevant resources have already been reclaimed. Ref:
48+ // https://github.com/kubernetes/cri-api/blob/c20fa40/pkg/apis/runtime/v1/api.proto#L45-L46
49+ return & runtime.StopPodSandboxResponse {}, nil
4350 }
4451
4552 if err := c .stopPodSandbox (ctx , sandbox ); err != nil {
You can’t perform that action at this time.
0 commit comments