From ccb2a8d747e710480613e0d8b61d82a7330a0d55 Mon Sep 17 00:00:00 2001 From: "jinda.ljd" Date: Sun, 29 Sep 2024 12:09:21 +0800 Subject: [PATCH] [cri] use 'UserSpecifiedImage' to set the image-name annotation However, when an image has multiple tags, the image originally obtained may not be the one actually specified by the user. Starting from cri-api v0.28.0, a UserSpecifiedImage field is added to ImageSpec. It is more appropriate to use UserSpecifiedImage. Signed-off-by: jinda.ljd --- internal/cri/server/container_create.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/cri/server/container_create.go b/internal/cri/server/container_create.go index 32523529c661..254d2079b2fe 100644 --- a/internal/cri/server/container_create.go +++ b/internal/cri/server/container_create.go @@ -183,6 +183,10 @@ func (c *criService) CreateContainer(ctx context.Context, r *runtime.CreateConta } log.G(ctx).Debugf("Use OCI runtime %+v for sandbox %q and container %q", ociRuntime, sandboxID, id) + imageName := containerdImage.Name() + if name := config.GetImage().GetUserSpecifiedImage(); name != "" { + imageName = name + } spec, err := c.buildContainerSpec( platform, id, @@ -190,7 +194,7 @@ func (c *criService) CreateContainer(ctx context.Context, r *runtime.CreateConta sandboxPid, sandbox.NetNSPath, containerName, - containerdImage.Name(), + imageName, config, sandboxConfig, &image.ImageSpec.Config,