Merge pull request #10521 from saschagrunert/idempotence-ctr
Make `StopContainer` RPC idempotent
This commit is contained in:
commit
7bcc78526d
@ -40,9 +40,16 @@ func (c *criService) StopContainer(ctx context.Context, r *runtime.StopContainer
|
|||||||
// Get container config from container store.
|
// Get container config from container store.
|
||||||
container, err := c.containerStore.Get(r.GetContainerId())
|
container, err := c.containerStore.Get(r.GetContainerId())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if !errdefs.IsNotFound(err) {
|
||||||
return nil, fmt.Errorf("an error occurred when try to find container %q: %w", r.GetContainerId(), 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 {
|
if err := c.stopContainer(ctx, container, time.Duration(r.GetTimeout())*time.Second); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user