sandbox: store endpoint in cri sandboxStore

Signed-off-by: Abel Feng <fshb1988@gmail.com>
This commit is contained in:
Abel Feng
2024-02-02 10:59:31 +08:00
parent f6e0cf1894
commit b1fefccc78
8 changed files with 74 additions and 9 deletions

View File

@@ -188,10 +188,13 @@ func (c *controllerLocal) Start(ctx context.Context, sandboxID string) (sandbox.
c.cleanupShim(ctx, sandboxID, svc)
return sandbox.ControllerInstance{}, fmt.Errorf("failed to start sandbox %s: %w", sandboxID, errdefs.FromGRPC(err))
}
address, protocol, version := shim.Endpoint()
return sandbox.ControllerInstance{
SandboxID: sandboxID,
Pid: resp.GetPid(),
Address: address,
Protocol: protocol,
Version: uint32(version),
CreatedAt: resp.GetCreatedAt().AsTime(),
}, nil
}
@@ -302,6 +305,12 @@ func (c *controllerLocal) Status(ctx context.Context, sandboxID string, verbose
return sandbox.ControllerStatus{}, fmt.Errorf("failed to query sandbox %s status: %w", sandboxID, err)
}
shim, err := c.shims.Get(ctx, sandboxID)
if err != nil {
return sandbox.ControllerStatus{}, fmt.Errorf("unable to find sandbox %q", sandboxID)
}
address, protocol, version := shim.Endpoint()
return sandbox.ControllerStatus{
SandboxID: resp.GetSandboxID(),
Pid: resp.GetPid(),
@@ -310,6 +319,9 @@ func (c *controllerLocal) Status(ctx context.Context, sandboxID string, verbose
CreatedAt: resp.GetCreatedAt().AsTime(),
ExitedAt: resp.GetExitedAt().AsTime(),
Extra: resp.GetExtra(),
Address: address,
Protocol: protocol,
Version: uint32(version),
}, nil
}