Skip to content

Commit

Permalink
Merge pull request containerd#10530 from k8s-infra-cherrypick-robot/c…
Browse files Browse the repository at this point in the history
…herry-pick-10521-to-release/1.6

[release/1.6] Make `StopContainer` RPC idempotent
  • Loading branch information
kzys authored Jul 31, 2024
2 parents f8c9d89 + 7134b03 commit 74f2f1b
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pkg/cri/server/container_stop.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,14 @@ func (c *criService) StopContainer(ctx context.Context, r *runtime.StopContainer
// Get container config from container store.
container, err := c.containerStore.Get(r.GetContainerId())
if err != nil {
return nil, fmt.Errorf("an error occurred when try to find container %q: %w", r.GetContainerId(), err)
if !errdefs.IsNotFound(err) {
return nil, fmt.Errorf("an error occurred when try to find container %q: %w", r.GetContainerId(), err)
}

// The StopContainer RPC is idempotent, and must not return an error if
// the container has already been stopped. Ref:
// https://github.com/kubernetes/cri-api/blob/c20fa40/pkg/apis/runtime/v1/api.proto#L67-L68
return &runtime.StopContainerResponse{}, nil
}

if err := c.stopContainer(ctx, container, time.Duration(r.GetTimeout())*time.Second); err != nil {
Expand Down

0 comments on commit 74f2f1b

Please sign in to comment.