Merge pull request #10520 from saschagrunert/cri

Make `StopPodSandbox` RPC idempotent
This commit is contained in:
Maksym Pavlenko 2024-07-30 20:12:50 +00:00 committed by GitHub
commit fec24e209d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -34,8 +34,15 @@ import (
func (c *criService) StopPodSandbox(ctx context.Context, r *runtime.StopPodSandboxRequest) (*runtime.StopPodSandboxResponse, error) { func (c *criService) StopPodSandbox(ctx context.Context, r *runtime.StopPodSandboxRequest) (*runtime.StopPodSandboxResponse, error) {
sandbox, err := c.sandboxStore.Get(r.GetPodSandboxId()) sandbox, err := c.sandboxStore.Get(r.GetPodSandboxId())
if err != nil { if err != nil {
return nil, fmt.Errorf("an error occurred when try to find sandbox %q: %w", if !errdefs.IsNotFound(err) {
r.GetPodSandboxId(), err) return nil, fmt.Errorf("an error occurred when try to find sandbox %q: %w",
r.GetPodSandboxId(), err)
}
// The StopPodSandbox RPC is idempotent, and must not return an error
// if all relevant resources have already been reclaimed. Ref:
// https://github.com/kubernetes/cri-api/blob/c20fa40/pkg/apis/runtime/v1/api.proto#L45-L46
return &runtime.StopPodSandboxResponse{}, nil
} }
if err := c.stopPodSandbox(ctx, sandbox); err != nil { if err := c.stopPodSandbox(ctx, sandbox); err != nil {