[sandbox] Don't access pause container when creating pod container

Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
This commit is contained in:
Maksym Pavlenko 2022-11-28 12:48:57 -08:00
parent cc111eef61
commit 9a53a6c34a

View File

@ -56,14 +56,21 @@ func (c *criService) CreateContainer(ctx context.Context, r *runtime.CreateConta
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to find sandbox id %q: %w", r.GetPodSandboxId(), err) return nil, fmt.Errorf("failed to find sandbox id %q: %w", r.GetPodSandboxId(), err)
} }
sandboxID := sandbox.ID
// TODO: Add PID endpoint to Controller interface. controller, err := c.getSandboxController(sandbox.Config, sandbox.RuntimeHandler)
s, err := sandbox.Container.Task(ctx, nil)
if err != nil { 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. // Generate unique id and name for the container and reserve the name.
// Reserve the container name to avoid concurrent `CreateContainer` request creating // Reserve the container name to avoid concurrent `CreateContainer` request creating