From 9a53a6c34a28ece2dfd549a25e7f0d6ecd31ca77 Mon Sep 17 00:00:00 2001 From: Maksym Pavlenko Date: Mon, 28 Nov 2022 12:48:57 -0800 Subject: [PATCH] [sandbox] Don't access pause container when creating pod container Signed-off-by: Maksym Pavlenko --- pkg/cri/sbserver/container_create.go | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) 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