kubevirt: Create VM says Could not open /dev/sysdisk: Permission denied

What happened: A clear and concise description of what the bug is.

create VM stuck on scheduled step

default     0s          Warning   SyncFailed                        virtualmachineinstance/vm-centos8     server error. command SyncVMI failed: "LibvirtError(Code=1, Domain=10, Message='internal error: process exited while connecting to monitor: 2022-05-11T06:11:55.380499Z qemu-kvm: -blockdev {\"driver\":\"host_device\",\"filename\":\"/dev/sysdisk\",\"node-name\":\"libvirt-3-storage\",\"cache\":{\"direct\":false,\"no-flush\":false},\"auto-read-only\":true,\"discard\":\"unmap\"}: Could not open '/dev/sysdisk': Permission denied')"

What you expected to happen: A clear and concise description of what you expected to happen. VM running success

How to reproduce it (as minimally and precisely as possible): Steps to reproduce the behavior. Create VM

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

vm

[root@hcit3 ~]# kubectl get vm,vmi,pod,pv,pvc,dv,vs,vsc
NAME                                    AGE   STATUS             READY
virtualmachine.kubevirt.io/vm-centos8   29m   CrashLoopBackOff   False

NAME                                             AGE   PHASE     IP            NODENAME                        READY
virtualmachineinstance.kubevirt.io/vmi-centos8   30m   Running   10.244.0.38   hcit3.cpp.bjzt.example.cn   True

NAME                                  READY   STATUS    RESTARTS   AGE
pod/virt-launcher-vmi-centos8-cqsp9   2/2     Running   0          30m

NAME                                                        CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS   CLAIM                STORAGECLASS   REASON   AGE
persistentvolume/pvc-7cd3bdb1-6eee-4a5e-9e2d-f11021106dfb   10Gi       RWX            Delete           Bound    default/centos8      cephcsi                 176m
persistentvolume/pvc-c05cff80-d163-4630-9e1a-0111788680ca   10Gi       RWX            Delete           Bound    default/vm-centos8   cephcsi                 29m

NAME                               STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS   AGE
persistentvolumeclaim/centos8      Bound    pvc-7cd3bdb1-6eee-4a5e-9e2d-f11021106dfb   10Gi       RWX            cephcsi        176m
persistentvolumeclaim/vm-centos8   Bound    pvc-c05cff80-d163-4630-9e1a-0111788680ca   10Gi       RWX            cephcsi        29m

NAME                                    PHASE       PROGRESS   RESTARTS   AGE
datavolume.cdi.kubevirt.io/centos8      Succeeded   N/A                   176m
datavolume.cdi.kubevirt.io/vm-centos8   Succeeded                         29m
[root@hcit3 ~]# kubectl get vm,vmi vm-centos8 -o yaml
apiVersion: v1
items:
- apiVersion: kubevirt.io/v1
  kind: VirtualMachine
  metadata:
    annotations:
      kubectl.kubernetes.io/last-applied-configuration: |
        {"apiVersion":"kubevirt.io/v1alpha3","kind":"VirtualMachine","metadata":{"annotations":{},"creationTimestamp":null,"labels":{"kubevirt.io/vm":"vm-centos8"},"name":"vm-centos8","namespace":"default"},"spec":{"dataVolumeTemplates":[{"metadata":{"creationTimestamp":null,"name":"vm-centos8"},"spec":{"pvc":{"accessModes":["ReadWriteMany"],"resources":{"requests":{"storage":"10Gi"}},"volumeMode":"Block"},"source":{"pvc":{"name":"centos8","namespace":"default"}}}}],"running":true,"template":{"metadata":{"labels":{"kubevirt.io/vm":"vm-datavolume"}},"spec":{"domain":{"devices":{"disks":[{"disk":{"bus":"virtio"},"name":"sysdisk"},{"disk":{"bus":"virtio"},"name":"emptydisk"},{"disk":{"bus":"virtio"},"name":"cloudinitdisk"}],"interfaces":[{"bridge":{},"name":"default"},{"bridge":{},"name":"br0-100"}]},"machine":{"type":""},"resources":{"requests":{"memory":"1024M"}}},"networks":[{"name":"default","pod":{}},{"multus":{"networkName":"a-bridge-network"},"name":"br0-100"}],"terminationGracePeriodSeconds":0,"volumes":[{"dataVolume":{"name":"vm-centos8"},"name":"sysdisk"},{"emptyDisk":{"capacity":"2Gi"},"name":"emptydisk"},{"cloudInitNoCloud":{"networkData":"version: 2\nethernets:\n  eth1:\n    addresses: [ 192.168.5.23/24 ]\n","userData":"#!/bin/bash\necho \"starting userdata\"\necho \"root\" |passwd root --stdin"},"name":"cloudinitdisk"}]}}}}
      kubevirt.io/latest-observed-api-version: v1
      kubevirt.io/storage-observed-api-version: v1alpha3
    creationTimestamp: "2022-05-11T05:52:08Z"
    generation: 1
    labels:
      kubevirt.io/vm: vm-centos8
    name: vm-centos8
    namespace: default
    resourceVersion: "6484444"
    uid: 59f5332c-e2dc-42f6-8cb0-ec4b8b8ec0b2
  spec:
    dataVolumeTemplates:
    - metadata:
        creationTimestamp: null
        name: vm-centos8
      spec:
        pvc:
          accessModes:
          - ReadWriteMany
          resources:
            requests:
              storage: 10Gi
          volumeMode: Block
        source:
          pvc:
            name: centos8
            namespace: default
    running: true
    template:
      metadata:
        creationTimestamp: null
        labels:
          kubevirt.io/vm: vm-datavolume
      spec:
        domain:
          devices:
            disks:
            - disk:
                bus: virtio
              name: sysdisk
            - disk:
                bus: virtio
              name: emptydisk
            - disk:
                bus: virtio
              name: cloudinitdisk
            interfaces:
            - bridge: {}
              name: default
            - bridge: {}
              name: br0-100
          machine:
            type: q35
          resources:
            requests:
              memory: 1024M
        networks:
        - name: default
          pod: {}
        - multus:
            networkName: a-bridge-network
          name: br0-100
        terminationGracePeriodSeconds: 0
        volumes:
        - dataVolume:
            name: vm-centos8
          name: sysdisk
        - emptyDisk:
            capacity: 2Gi
          name: emptydisk
        - cloudInitNoCloud:
            networkData: |
              version: 2
              ethernets:
                eth1:
                  addresses: [ 192.168.5.23/24 ]
            userData: |-
              #!/bin/bash
              echo "starting userdata"
              echo "root" |passwd root --stdin
          name: cloudinitdisk
  status:
    conditions:
    - lastProbeTime: "2022-05-11T06:53:57Z"
      lastTransitionTime: "2022-05-11T06:53:57Z"
      message: VMI does not exist
      reason: VMINotExists
      status: "False"
      type: Ready
    - lastProbeTime: null
      lastTransitionTime: null
      message: cannot migrate VMI which does not use masquerade to connect to the
        pod network
      reason: InterfaceNotLiveMigratable
      status: "False"
      type: LiveMigratable
    printableStatus: CrashLoopBackOff
    startFailure:
      consecutiveFailCount: 8
      lastFailedVMIUID: a16c3606-7bf2-411c-9d8b-fe1305457fd2
      retryAfterTimestamp: "2022-05-11T06:58:57Z"
    volumeSnapshotStatuses:
    - enabled: true
      name: sysdisk
    - enabled: false
      name: emptydisk
      reason: Snapshot is not supported for this volumeSource type [emptydisk]
    - enabled: false
      name: cloudinitdisk
      reason: Snapshot is not supported for this volumeSource type [cloudinitdisk]
kind: List
metadata:
  resourceVersion: ""
  selfLink: ""
Error from server (NotFound): virtualmachineinstances.kubevirt.io "vm-centos8" not found

Details

[root@hcit3 ~]# kubectl get pods -A
NAMESPACE            NAME                                                    READY   STATUS    RESTARTS       AGE
cdi                  cdi-apiserver-76cc997b59-cctbv                          1/1     Running   1 (21h ago)    11d
cdi                  cdi-deployment-5976d8fd44-lwwnb                         1/1     Running   2 (21h ago)    11d
cdi                  cdi-operator-7d8958f8f7-jqpzs                           1/1     Running   1 (21h ago)    11d
cdi                  cdi-uploadproxy-5b675bbc45-tdws9                        1/1     Running   1 (21h ago)    11d
ceph-csi-rbd         ceph-csi-rbd-nodeplugin-4dsf5                           3/3     Running   0              158m
ceph-csi-rbd         ceph-csi-rbd-provisioner-757f8c75fd-2gb65               7/7     Running   0              158m
default              virt-launcher-vm-centos8-k9k97                          1/1     Running   0              25s
default              virt-launcher-vmi-centos8-cqsp9                         2/2     Running   0              32m
kube-system          coredns-589cd7dcc8-58f7j                                1/1     Running   1 (21h ago)    13d
kube-system          coredns-589cd7dcc8-q24hz                                1/1     Running   1 (21h ago)    13d
kube-system          csi-attacher-6cb8bf54cf-79frd                           2/2     Running   0              156m
kube-system          csi-resizer-6cbf5b49c-rckbw                             2/2     Running   0              156m
kube-system          csi-snapshotter-0                                       3/3     Running   0              150m
kube-system          etcd-hcit3.cpp.bjzt.example.cn                      1/1     Running   1 (21h ago)    13d
kube-system          kube-apiserver-hcit3.cpp.bjzt.example.cn            1/1     Running   1 (21h ago)    13d
kube-system          kube-controller-manager-hcit3.cpp.bjzt.example.cn   1/1     Running   1 (21h ago)    13d
kube-system          kube-flannel-ds-px24m                                   1/1     Running   1 (21h ago)    43h
kube-system          kube-multus-ds-6bk8j                                    1/1     Running   1 (21h ago)    13d
kube-system          kube-proxy-w657c                                        1/1     Running   1 (21h ago)    13d
kube-system          kube-scheduler-hcit3.cpp.bjzt.example.cn            1/1     Running   1 (21h ago)    13d
kube-system          snapshot-controller-85c64bc56d-tzpwl                    1/1     Running   2 (149m ago)   150m
kube-system          snapshot-validation-deployment-864c56748d-dx6hl         1/1     Running   1 (21h ago)    4d22h
kubevirt             virt-api-79bbdb68b6-d9kvr                               1/1     Running   3 (21h ago)    13d
kubevirt             virt-controller-59ddd79477-lpp7l                        1/1     Running   1 (21h ago)    3d20h
kubevirt             virt-handler-gh4rv                                      1/1     Running   1 (21h ago)    13d
kubevirt             virt-operator-94b6779f9-j7zrz                           1/1     Running   2 (21h ago)    13d
kubevirt             virtvnc-66f9b9c789-6ltvk                                1/1     Running   1 (21h ago)    4d20h
local-path-storage   local-path-provisioner-5c6f84ff44-skvtx                 1/1     Running   1 (21h ago)    13d
[root@hcit3 ~]# kubectl get sc -o yaml cephcsi
allowVolumeExpansion: true
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"allowVolumeExpansion":true,"apiVersion":"storage.k8s.io/v1","kind":"StorageClass","metadata":{"annotations":{},"name":"cephcsi"},"mountOptions":["discard"],"parameters":{"clusterID":"59745df0-d04d-11ec-b403-fa163d0991c5","csi.storage.k8s.io/controller-expand-secret-name":"csi-rbd-secret","csi.storage.k8s.io/controller-expand-secret-namespace":"ceph-csi-rbd","csi.storage.k8s.io/fstype":"ext4","csi.storage.k8s.io/node-stage-secret-name":"csi-rbd-secret","csi.storage.k8s.io/node-stage-secret-namespace":"ceph-csi-rbd","csi.storage.k8s.io/provisioner-secret-name":"csi-rbd-secret","csi.storage.k8s.io/provisioner-secret-namespace":"ceph-csi-rbd","imageFeatures":"layering","pool":"kubernetes"},"provisioner":"rbd.csi.ceph.com","reclaimPolicy":"Delete"}
    storageclass.kubernetes.io/is-default-class: "true"
  creationTimestamp: "2022-05-11T03:23:58Z"
  name: cephcsi
  resourceVersion: "6402756"
  uid: 14c360b5-5e1d-425d-a2d1-9ea5bdab896c
mountOptions:
- discard
parameters:
  clusterID: 59745df0-d04d-11ec-b403-fa163d0991c5
  csi.storage.k8s.io/controller-expand-secret-name: csi-rbd-secret
  csi.storage.k8s.io/controller-expand-secret-namespace: ceph-csi-rbd
  csi.storage.k8s.io/fstype: ext4
  csi.storage.k8s.io/node-stage-secret-name: csi-rbd-secret
  csi.storage.k8s.io/node-stage-secret-namespace: ceph-csi-rbd
  csi.storage.k8s.io/provisioner-secret-name: csi-rbd-secret
  csi.storage.k8s.io/provisioner-secret-namespace: ceph-csi-rbd
  imageFeatures: layering
  pool: kubernetes
provisioner: rbd.csi.ceph.com
reclaimPolicy: Delete
volumeBindingMode: Immediate

Environment:

  • KubeVirt version (use virtctl version):
[root@hcit3 ~]# virtctl version
Client Version: version.Info{GitVersion:"v0.52.0", GitCommit:"836afc8c556206fc7715615ddb6516d76f4240db", GitTreeState:"clean", BuildDate:"2022-04-08T16:25:37Z", GoVersion:"go1.17.5", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{GitVersion:"v0.52.0", GitCommit:"836afc8c556206fc7715615ddb6516d76f4240db", GitTreeState:"clean", BuildDate:"2022-04-08T16:25:37Z", GoVersion:"go1.17.5", Compiler:"gc", Platform:"linux/amd64"}
  • Kubernetes version (use kubectl version):
[root@hcit3 ~]# kubectl version
Client Version: version.Info{Major:"1", Minor:"23", GitVersion:"v1.23.6", GitCommit:"ad3338546da947756e8a88aa6822e9c11e7eac22", GitTreeState:"clean", BuildDate:"2022-04-14T08:49:13Z", GoVersion:"go1.17.9", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"23", GitVersion:"v1.23.6", GitCommit:"ad3338546da947756e8a88aa6822e9c11e7eac22", GitTreeState:"clean", BuildDate:"2022-04-14T08:43:11Z", GoVersion:"go1.17.9", Compiler:"gc", Platform:"linux/amd64"}
  • VM or VMI specifications:

both following guest os have same eror:

  1. CentOS-8-GenericCloud-8.4.2105-20210603.0.x86_64.qcow2
  2. Fedora-Cloud-Base-34-1.2.x86_64.qcow2
piVersion: kubevirt.io/v1alpha3
kind: VirtualMachine
metadata:
  creationTimestamp: null
  labels:
    kubevirt.io/vm: vm-centos8
  name: vm-centos8
spec:
  dataVolumeTemplates:
  - metadata:
      creationTimestamp: null
      name: vm-centos8
    spec:
      pvc:
        accessModes:
        - ReadWriteMany
        volumeMode: Block
        resources:
          requests:
            storage: 10Gi
        # storageClassName: example-local-pv
      source:
        pvc:
          name: centos8
          namespace: default
  running: true
  template:
    metadata:
      labels:
        kubevirt.io/vm: vm-datavolume
    spec:
      domain:
        resources:
          requests:
            memory: 1024M
        devices:
          disks:
          - disk:
              bus: virtio
            name: sysdisk
          - name: emptydisk
            disk:
              bus: virtio
          - disk:
              bus: virtio
            name: cloudinitdisk
          interfaces:
          - name: default
            bridge: {}
          - name: br0-100
            bridge: {}
        machine:
          type: ""
      networks:
      - name: default
        pod: {}
      - name: br0-100
        multus:
          networkName: a-bridge-network
      terminationGracePeriodSeconds: 0
      volumes:
      - dataVolume:
          name: vm-centos8
        name: sysdisk
      - name: emptydisk
        emptyDisk:
          capacity: "2Gi"
      - name: cloudinitdisk
        cloudInitNoCloud:
          networkData: |
            version: 2
            ethernets:
              eth1:
                addresses: [ 192.168.5.23/24 ]
          userData: |-
            #!/bin/bash
            echo "starting userdata"
            echo "root" |passwd root --stdin
  • Cloud provider or hardware configuration:
product: RH2288H V3 (Type1Sku0)
    vendor: Huawei
    version: V100R003
  • OS (e.g. from /etc/os-release):
[root@hcit3 ~]# cat /etc/os-release
NAME="CentOS Linux"
VERSION="8"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="8"
PLATFORM_ID="platform:el8"
PRETTY_NAME="CentOS Linux 8"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:8"
HOME_URL="https://centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"
CENTOS_MANTISBT_PROJECT="CentOS-8"
CENTOS_MANTISBT_PROJECT_VERSION="8"
  • Kernel (e.g. uname -a):
[root@hcit3 ~]# uname -a
Linux hcit3.cpp.bjzt.example.cn 4.18.0-305.3.1.el8.x86_64 #1 SMP Tue Jun 1 16:14:33 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
  • Install tools: ceph-csi, flannel
  • Others: N/A

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 38 (22 by maintainers)

Most upvoted comments

@fabiand What i discovered so far is that this relates to the securityContext of the virthandler (which now runs as nonroot). In this case I did try a solution from another issue (https://github.com/kubevirt/containerized-data-importer/issues/2378#issuecomment-1297007860) and it worked in our setup.

I’ve outlined it here; https://blog.nuvotex.de/p/988ef27e-29fa-4e32-a82f-ccfc23b2f967/