Skip to content

Commit

Permalink
Use the containerdisk image name from the VMI spec
Browse files Browse the repository at this point in the history
It appears that ContainerStatuses[].Image from the Pod spec cannot be
used to reliably identify the name of the containerdisk image. E.g.
while testing the bellow containerdisk:

    quay.io/kubevirt/fedora-with-test-tooling-container-disk:v0.57.0

it was observed with containerd that ContainerStatuses[].Image may
contain either an internal image ID in the form of:

    sha256:e3559e53b6b1df866598887793f94b9908d3a7e343f4a6394670d69fbe511cb2

or the image can be resolved to an alias:

    192.168.122.1:5000/fedora-with-test-tooling-container-disk@sha256:30750fe1f8936e21890a4e45289ec3afdbcae3d9072ec7d7629ec20f4afbd00e

This eventually breaks live migration, as such references cannot be
resolved on the target node.

To solve the issue, the final pullable reference is now composed using
the base image name from the VMI spec and the unique SHA digest is taken
from ContainerStatuses[].ImageID of the Pod spec.

Signed-off-by: Vasiliy Ulyanov <[email protected]>
  • Loading branch information
vasiliy-ul committed Sep 15, 2022
1 parent 2e06ef9 commit 77fe8ed
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions pkg/container-disk/container-disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,22 +384,23 @@ func ExtractImageIDsFromSourcePod(vmi *v1.VirtualMachineInstance, sourcePod *kub
if volume.ContainerDisk == nil {
continue
}
imageIDs[volume.Name] = ""
imageIDs[volume.Name] = volume.ContainerDisk.Image
}

if util.HasKernelBootContainerImage(vmi) {
imageIDs[KernelBootVolumeName] = ""
imageIDs[KernelBootVolumeName] = vmi.Spec.Domain.Firmware.KernelBoot.Container.Image
}

for _, status := range sourcePod.Status.ContainerStatuses {
if !isImageVolume(status.Name) {
continue
}
key := toVolumeName(status.Name)
if _, exists := imageIDs[key]; !exists {
image, exists := imageIDs[key]
if !exists {
continue
}
imageID, err := toImageWithDigest(status.Image, status.ImageID)
imageID, err := toImageWithDigest(image, status.ImageID)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 77fe8ed

Please sign in to comment.