From 3ddaa3444588a36a3e8a853034be839d66049e23 Mon Sep 17 00:00:00 2001 From: Maksym Pavlenko Date: Thu, 17 Nov 2022 12:19:58 -0800 Subject: [PATCH] Retrieve sandbox creation time from store. All pause container object references must be removed from sbserver. This is an implementation detail of podsandbox package. Added TODOs for remaining work. Signed-off-by: Maksym Pavlenko --- pkg/cri/sbserver/sandbox_status.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pkg/cri/sbserver/sandbox_status.go b/pkg/cri/sbserver/sandbox_status.go index 97e8aae4e..2426dd0a0 100644 --- a/pkg/cri/sbserver/sandbox_status.go +++ b/pkg/cri/sbserver/sandbox_status.go @@ -45,12 +45,13 @@ func (c *criService) PodSandboxStatus(ctx context.Context, r *runtime.PodSandbox status := toCRISandboxStatus(sandbox.Metadata, sandbox.Status.Get(), ip, additionalIPs) if status.GetCreatedAt() == 0 { // CRI doesn't allow CreatedAt == 0. - info, err := sandbox.Container.Info(ctx) + sandboxInfo, err := c.client.SandboxStore().Get(ctx, r.GetPodSandboxId()) if err != nil { - return nil, fmt.Errorf("failed to get CreatedAt for sandbox container in %q state: %w", status.State, err) + return nil, fmt.Errorf("failed to get sandbox %q from metadata store: %w", r.GetPodSandboxId(), err) } - status.CreatedAt = info.CreatedAt.UnixNano() + status.CreatedAt = sandboxInfo.CreatedAt.UnixNano() } + if !r.GetVerbose() { return &runtime.PodSandboxStatusResponse{Status: status}, nil } @@ -76,10 +77,15 @@ func (c *criService) getIPs(sandbox sandboxstore.Sandbox) (string, []string, err // responsible for reporting the IP. return "", nil, nil } + if goruntime.GOOS == "windows" && config.GetWindows().GetSecurityContext().GetHostProcess() { return "", nil, nil } + if goruntime.GOOS == "darwin" { + return "", nil, nil + } + if closed, err := sandbox.NetNS.Closed(); err != nil { return "", nil, fmt.Errorf("check network namespace closed: %w", err) } else if closed {