kubevirt: VirtualMachines with bad kernelBoot container get stuck terminating

What happened: When specifying a kernelBoot.container.image with an image which does not have a valid initrd or kernel (for example, an nginx container). The VMI is stuck terminating until the finalizer foregroundDeleteVirtualMachine is manually removed.

What you expected to happen: Regardless of data provided in a VM manifest, the pod will be able to terminate and clean up after a period of time.

How to reproduce it (as minimally and precisely as possible): Apply a VMI similar to this:

apiVersion: kubevirt.io/v1
kind: VirtualMachineInstance
metadata:
  name: vmi-gets-stuck
spec:
  domain:
    cpu:
      model: host-passthrough
    devices:
      disks:
      - disk:
          bus: virtio
        name: containerdisk
      - disk:
          bus: virtio
        name: emptydisk
      interfaces:
      - bridge: {}
        name: default
    features:
      acpi:
        enabled: true
    firmware:
      bootloader:
        efi:
          secureBoot: false
      kernelBoot:
        container:
          image: nginx
          initrdPath: /sbin/init
    machine:
      type: q35
    resources:
      limits:
        cpu: "4"
        memory: 32Gi
  networks:
  - name: default
    pod: {}
  volumes:
  - containerDisk:
      image: tedezed/debian-container-disk:10.0
      imagePullPolicy: IfNotPresent
    name: containerdisk
  - emptyDisk:
      capacity: 64Gi
    name: emptydisk

There are several errors in the virt-handler pod logs for that node while the VMI is running:

virt-handler-f5njw virt-handler {"component":"virt-handler","level":"info","msg":"resyncing virt-launcher domains","pos":"cache.go:385","timestamp":"2023-09-11T20:46:28.948569Z"}
virt-handler-f5njw virt-handler {"component":"virt-handler","kind":"","level":"info","msg":"VMI is in phase: Scheduled | Domain does not exist","name":"vmi-gets-stuck","namespace":"user-jcichra","pos":"vm.go:1684","timestamp":"2023-09-11T20:46:30.613560Z","uid":"322d565b-9486-44cb-a32a-0b2ec24cae36"}
virt-handler-f5njw virt-handler {"component":"virt-handler","kind":"","level":"info","msg":"mounting kernel artifacts","name":"vmi-gets-stuck","namespace":"user-jcichra","pos":"mount.go:405","timestamp":"2023-09-11T20:46:30.640811Z","uid":"322d565b-9486-44cb-a32a-0b2ec24cae36"}
virt-handler-f5njw virt-handler {"component":"virt-handler","kind":"","level":"error","msg":"Synchronizing the VirtualMachineInstance failed.","name":"vmi-gets-stuck","namespace":"user-jcichra","pos":"vm.go:1830","reason":"error mounting kernel artifacts: failed making the directory root: /, relative: /state/var/lib/kubelet/pods/20d78b8a-2a36-4f94-96e8-6e260f64303a/volumes/kubernetes.io~empty-dir/container-disks: file exists","timestamp":"2023-09-11T20:46:30.641042Z","uid":"322d565b-9486-44cb-a32a-0b2ec24cae36"}
virt-handler-f5njw virt-handler {"component":"virt-handler","kind":"","level":"info","msg":"migration is block migration because of containerdisk volume","name":"vmi-gets-stuck","namespace":"user-jcichra","pos":"vm.go:2349","timestamp":"2023-09-11T20:46:30.661292Z","uid":"322d565b-9486-44cb-a32a-0b2ec24cae36"}
virt-handler-f5njw virt-handler {"component":"virt-handler","kind":"","level":"info","msg":"migration is block migration because of emptydisk volume","name":"vmi-gets-stuck","namespace":"user-jcichra","pos":"vm.go:2349","timestamp":"2023-09-11T20:46:30.661365Z","uid":"322d565b-9486-44cb-a32a-0b2ec24cae36"}
virt-handler-f5njw virt-handler {"component":"virt-handler","level":"info","msg":"re-enqueuing VirtualMachineInstance user-jcichra/vmi-gets-stuck","pos":"vm.go:1474","reason":"error mounting kernel artifacts: failed making the directory root: /, relative: /state/var/lib/kubelet/pods/20d78b8a-2a36-4f94-96e8-6e260f64303a/volumes/kubernetes.io~empty-dir/container-disks: file exists","timestamp":"2023-09-11T20:46:30.661440Z"}
virt-handler-f5njw virt-handler {"component":"virt-handler","level":"info","msg":"disappearing VM on //pods/20d78b8a-2a36-4f94-96e8-6e260f64303a/volumes/kubernetes.io~empty-dir/sockets/launcher-sock, ignored","pos":"prometheus.go:636","timestamp":"2023-09-11T20:46:33.717736Z"}
virt-handler-f5njw virt-handler {"component":"virt-handler","level":"info","msg":"disappearing VM on //pods/20d78b8a-2a36-4f94-96e8-6e260f64303a/volumes/kubernetes.io~empty-dir/sockets/launcher-sock, ignored","pos":"prometheus.go:636","timestamp":"2023-09-11T20:46:48.293655Z"}
virt-handler-f5njw virt-handler {"component":"virt-handler","level":"info","msg":"disappearing VM on //pods/20d78b8a-2a36-4f94-96e8-6e260f64303a/volumes/kubernetes.io~empty-dir/sockets/launcher-sock, ignored","pos":"prometheus.go:636","timestamp":"2023-09-11T20:46:53.717542Z"}
virt-handler-f5njw virt-handler {"component":"virt-handler","level":"info","msg":"disappearing VM on //pods/20d78b8a-2a36-4f94-96e8-6e260f64303a/volumes/kubernetes.io~empty-dir/sockets/launcher-sock, ignored","pos":"prometheus.go:636","timestamp":"2023-09-11T20:47:08.290049Z"}
virt-handler-f5njw virt-handler {"component":"virt-handler","level":"info","msg":"disappearing VM on //pods/20d78b8a-2a36-4f94-96e8-6e260f64303a/volumes/kubernetes.io~empty-dir/sockets/launcher-sock, ignored","pos":"prometheus.go:636","timestamp":"2023-09-11T20:47:13.718353Z"}
virt-handler-f5njw virt-handler {"component":"virt-handler","level":"error","msg":"failed to remove mdev types: failed to read the content of /sys/bus/mdev/devices directory","pos":"mediated_devices_types.go:263","reason":"open /sys/bus/mdev/devices: no such file or directory","timestamp":"2023-09-11T20:47:24.625913Z"}
virt-handler-f5njw virt-handler {"component":"virt-handler","level":"info","msg":"refreshed device plugins for permitted/forbidden host devices","pos":"device_controller.go:321","timestamp":"2023-09-11T20:47:24.625983Z"}
virt-handler-f5njw virt-handler {"component":"virt-handler","level":"info","msg":"enabled device-plugins for: []","pos":"device_controller.go:322","timestamp":"2023-09-11T20:47:24.626003Z"}
virt-handler-f5njw virt-handler {"component":"virt-handler","level":"info","msg":"disabled device-plugins for: []","pos":"device_controller.go:323","timestamp":"2023-09-11T20:47:24.626015Z"}
virt-handler-f5njw virt-handler {"component":"virt-handler","level":"info","msg":"disappearing VM on //pods/20d78b8a-2a36-4f94-96e8-6e260f64303a/volumes/kubernetes.io~empty-dir/sockets/launcher-sock, ignored","pos":"prometheus.go:636","timestamp":"2023-09-11T20:47:28.290249Z"}

When deleting the VMI, this error occurs:

virt-handler-f5njw virt-handler {"component":"virt-handler","level":"info","msg":"re-enqueuing VirtualMachineInstance user-jcichra/vmi-gets-stuck","pos":"vm.go:1474","reason":"error unmounting kernel artifacts: kernel artifacts record wasn't found","timestamp":"2023-09-11T20:49:39.948277Z"}
virt-handler-f5njw virt-handler {"component":"virt-handler","kind":"","level":"info","msg":"VMI is in phase: Failed | Domain does not exist","name":"vmi-gets-stuck","namespace":"user-jcichra","pos":"vm.go:1684","timestamp":"2023-09-11T20:49:46.434582Z","uid":"322d565b-9486-44cb-a32a-0b2ec24cae36"}
virt-handler-f5njw virt-handler {"component":"virt-handler","kind":"","level":"info","msg":"Performing final local cleanup for vmi with uid 322d565b-9486-44cb-a32a-0b2ec24cae36","name":"vmi-gets-stuck","namespace":"user-jcichra","pos":"vm.go:1948","timestamp":"2023-09-11T20:49:46.434708Z","uid":"322d565b-9486-44cb-a32a-0b2ec24cae36"}
virt-handler-f5njw virt-handler {"component":"virt-handler","kind":"","level":"info","msg":"unmounting kernel artifacts","name":"vmi-gets-stuck","namespace":"user-jcichra","pos":"mount.go:547","timestamp":"2023-09-11T20:49:46.434787Z","uid":"322d565b-9486-44cb-a32a-0b2ec24cae36"}
virt-handler-f5njw virt-handler {"component":"virt-handler","level":"info","msg":"re-enqueuing VirtualMachineInstance user-jcichra/vmi-gets-stuck","pos":"vm.go:1474","reason":"error unmounting kernel artifacts: kernel artifacts record wasn't found","timestamp":"2023-09-11T20:49:46.434812Z"}
virt-handler-f5njw virt-handler {"component":"virt-handler","kind":"Domain","level":"warning","msg":"detected unresponsive virt-launcher command socket (//pods/20d78b8a-2a36-4f94-96e8-6e260f64303a/volumes/kubernetes.io~empty-dir/sockets/launcher-sock) for domain","name":"vmi-gets-stuck","namespace":"user-jcichra","pos":"cache.go:481","timestamp":"2023-09-11T20:49:50.948682Z","uid":"322d565b-9486-44cb-a32a-0b2ec24cae36"}
virt-handler-f5njw virt-handler {"component":"virt-handler","level":"error","msg":"Unable to mark vmi as unresponsive socket //pods/20d78b8a-2a36-4f94-96e8-6e260f64303a/volumes/kubernetes.io~empty-dir/sockets/launcher-sock","pos":"cache.go:486","reason":"open /pods/20d78b8a-2a36-4f94-96e8-6e260f64303a/volumes/kubernetes.io~empty-dir/sockets/launcher-unresponsive: no such file or directory","timestamp":"2023-09-11T20:49:50.948735Z"}
virt-handler-f5njw virt-handler {"component":"virt-handler","kind":"Domain","level":"info","msg":"Domain is marked for deletion","name":"vmi-gets-stuck","namespace":"user-jcichra","pos":"vm.go:3056","timestamp":"2023-09-11T20:49:50.948778Z","uid":"322d565b-9486-44cb-a32a-0b2ec24cae36"}
virt-handler-f5njw virt-handler {"component":"virt-handler","kind":"","level":"info","msg":"VMI is in phase: Failed | Domain does not exist","name":"vmi-gets-stuck","namespace":"user-jcichra","pos":"vm.go:1684","timestamp":"2023-09-11T20:49:50.948828Z","uid":"322d565b-9486-44cb-a32a-0b2ec24cae36"}
virt-handler-f5njw virt-handler {"component":"virt-handler","kind":"","level":"info","msg":"Performing final local cleanup for vmi with uid 322d565b-9486-44cb-a32a-0b2ec24cae36","name":"vmi-gets-stuck","namespace":"user-jcichra","pos":"vm.go:1948","timestamp":"2023-09-11T20:49:50.948861Z","uid":"322d565b-9486-44cb-a32a-0b2ec24cae36"}
virt-handler-f5njw virt-handler {"component":"virt-handler","kind":"","level":"info","msg":"unmounting kernel artifacts","name":"vmi-gets-stuck","namespace":"user-jcichra","pos":"mount.go:547","timestamp":"2023-09-11T20:49:50.948891Z","uid":"322d565b-9486-44cb-a32a-0b2ec24cae36"}
virt-handler-f5njw virt-handler {"component":"virt-handler","level":"info","msg":"re-enqueuing VirtualMachineInstance user-jcichra/vmi-gets-stuck","pos":"vm.go:1474","reason":"error unmounting kernel artifacts: kernel artifacts record wasn't found","timestamp":"2023-09-11T20:49:50.948913Z"}

Additional context: Add any other context about the problem here.

Environment:

  • KubeVirt version (use virtctl version): v0.59.0
  • Kubernetes version (use kubectl version): 1.24.14
  • VM or VMI specifications: (See example)
  • Cloud provider or hardware configuration: Bare Metal
  • OS (e.g. from /etc/os-release): Debian Bookworm
  • Kernel (e.g. uname -a): 6.1.51
  • Install tools: N/A
  • Others: N/A

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Comments: 26 (24 by maintainers)

Most upvoted comments

@aliamerj Yes, I think this is the right way of thinking. As the author said:

When specifying a kernelBoot.container.image with an image which does not have a valid initrd or kernel (for example, an nginx container).

So I guess that we need some validation to make sure these paths exist, and then instead trying to mount them and fail we should fail fast with a proper error.

I reduced the memory on the vmi and increased the memory’s the cluster and manage to point to vmis to my docker hub account and now i reproduce the issue thank you.

@aliamerj mind the following line:

0/1 nodes are available: 1 Insufficient memory. preemption: 0/1 nodes are available: 1 No preemption victims found for incoming pod.

Please reduce the memory request to make sure it schedules.

/remove-lifecycle rotten /cc @xpivarc (doesn’t look like it worked the first time)