diff --git a/pkg/cri/sbserver/container_create.go b/pkg/cri/sbserver/container_create.go index f1c70a38b..4ba4e1375 100644 --- a/pkg/cri/sbserver/container_create.go +++ b/pkg/cri/sbserver/container_create.go @@ -56,14 +56,21 @@ func (c *criService) CreateContainer(ctx context.Context, r *runtime.CreateConta if err != nil { return nil, fmt.Errorf("failed to find sandbox id %q: %w", r.GetPodSandboxId(), err) } - sandboxID := sandbox.ID - // TODO: Add PID endpoint to Controller interface. - s, err := sandbox.Container.Task(ctx, nil) + controller, err := c.getSandboxController(sandbox.Config, sandbox.RuntimeHandler) if err != nil { - return nil, fmt.Errorf("failed to get sandbox container task: %w", err) + return nil, fmt.Errorf("failed to get sandbox controller: %w", err) } - sandboxPid := s.Pid() + + statusResponse, err := controller.Status(ctx, sandbox.ID, false) + if err != nil { + return nil, fmt.Errorf("failed to get controller status: %w", err) + } + + var ( + sandboxID = statusResponse.GetID() + sandboxPid = statusResponse.GetPid() + ) // Generate unique id and name for the container and reserve the name. // Reserve the container name to avoid concurrent `CreateContainer` request creating