Skip to content

Commit ccb2a8d

Browse files
committed
[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 <[email protected]>
1 parent 86e0f52 commit ccb2a8d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

internal/cri/server/container_create.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,14 +183,18 @@ func (c *criService) CreateContainer(ctx context.Context, r *runtime.CreateConta
183183
}
184184
log.G(ctx).Debugf("Use OCI runtime %+v for sandbox %q and container %q", ociRuntime, sandboxID, id)
185185

186+
imageName := containerdImage.Name()
187+
if name := config.GetImage().GetUserSpecifiedImage(); name != "" {
188+
imageName = name
189+
}
186190
spec, err := c.buildContainerSpec(
187191
platform,
188192
id,
189193
sandboxID,
190194
sandboxPid,
191195
sandbox.NetNSPath,
192196
containerName,
193-
containerdImage.Name(),
197+
imageName,
194198
config,
195199
sandboxConfig,
196200
&image.ImageSpec.Config,

0 commit comments

Comments
 (0)