File tree Expand file tree Collapse file tree 2 files changed +19
-4
lines changed Expand file tree Collapse file tree 2 files changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ import (
22
22
"fmt"
23
23
"time"
24
24
25
+ "github.com/containerd/errdefs"
25
26
"github.com/containerd/log"
26
27
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
27
28
@@ -33,8 +34,15 @@ import (
33
34
func (c * criService ) StopPodSandbox (ctx context.Context , r * runtime.StopPodSandboxRequest ) (* runtime.StopPodSandboxResponse , error ) {
34
35
sandbox , err := c .sandboxStore .Get (r .GetPodSandboxId ())
35
36
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
38
46
}
39
47
40
48
if err := c .stopPodSandbox (ctx , sandbox ); err != nil {
Original file line number Diff line number Diff line change @@ -38,8 +38,15 @@ import (
38
38
func (c * criService ) StopPodSandbox (ctx context.Context , r * runtime.StopPodSandboxRequest ) (* runtime.StopPodSandboxResponse , error ) {
39
39
sandbox , err := c .sandboxStore .Get (r .GetPodSandboxId ())
40
40
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
43
50
}
44
51
45
52
if err := c .stopPodSandbox (ctx , sandbox ); err != nil {
You can’t perform that action at this time.
0 commit comments