Skip to content

Commit

Permalink
[cri] use 'UserSpecifiedImage' to set the image-name annotation
Browse files Browse the repository at this point in the history
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 <jinda.ljd@alibaba-inc.com>
  • Loading branch information
jinda.ljd committed Sep 30, 2024
1 parent 86e0f52 commit ccb2a8d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion internal/cri/server/container_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,14 +183,18 @@ 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,
sandboxID,
sandboxPid,
sandbox.NetNSPath,
containerName,
containerdImage.Name(),
imageName,
config,
sandboxConfig,
&image.ImageSpec.Config,
Expand Down

0 comments on commit ccb2a8d

Please sign in to comment.