[sandbox] Don't access pause container when creating pod container
@@ -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
