Skip to content

Can't provision VM from template #289

Open
@Zeashh

Description

@Zeashh

When trying to provision a VM from a template, we get 2 distinct errors:

  • when provisioning from a default template (rhel9-server-small):
<AEMethod update_provision_status> VM Provision Error: [EVM] VM [provision-test-rhel9] Step [CheckProvisioned] Status [Error Creating VM] Message [[Fog::Kubevirt::Errors::ClientError]: HTTP status code 422, admission webhook "virtualmachine-validator.kubevirt.io" denied the request: spec.template.spec.volumes[1].cloudInitNoCloud must have at least one userdatasource or one networkdatasource set. for]
  • when provisioning from a custom Ubuntu template (YAML provided below):
<AEMethod update_provision_status> VM Provision Error: [EVM] VM [provision-test-ubuntu] Step [CheckProvisioned] Status [Error Creating VM] Message [[Fog::Kubevirt::Errors::ClientError]: HTTP status code 422, admission webhook "virtualmachine-validator.kubevirt.io" denied the request: Running and RunStrategy are mutually exclusive for POST https://ocp.domain.com:6443/apis/kubevirt.io/v1/namesp]

Both templates work when used the same way from the Openshift console. I'll also note that we're never given the choice to choose the datastore for the VM disk.

Steps to reproduce:

  • Select desired VM template
  • Click "Lifecycle" and choose "Provision VMs using this Template"
  • Fill out form only with necessary information (e-mail. VM name)
  • Submit form
  • Approve VM creation request
  • See errors above depending on the chosen template

Versions:

  • ManageIQ: radjabov-1.20250408024349_e386fb4
  • Openshift: 4.18.8 (error persisted throughout several 4.17.X versions while we were in the process of upgrading)

Aforementioned Ubuntu template:

kind: Template
apiVersion: template.openshift.io/v1
metadata:
  name: ubuntu-2204
  namespace: default
  labels:
    os.template.kubevirt.io/ubuntu: 'true'
    template.kubevirt.io/type: vm
    workload.template.kubevirt.io/server: 'true'
  annotations:
    description: Ubuntu 22.04 VM template
    iconClass: icon-ubuntu
    name.os.template.kubevirt.io/ubuntu: Ubuntu
    openshift.io/display-name: Ubuntu VM
objects:
  - apiVersion: kubevirt.io/v1
    kind: VirtualMachine
    metadata:
      name: '${NAME}'
      annotations:
        description: Ubuntu 22.04 VM
      labels:
        app: '${NAME}'
        vm.kubevirt.io/template: ubuntu-2204
        os.template.kubevirt.io/ubuntu: 'true'
    spec:
      dataVolumeTemplates:
        - apiVersion: cdi.kubevirt.io/v1beta1
          kind: DataVolume
          metadata:
            name: '${NAME}'
          spec:
            sourceRef:
              kind: DataSource
              name: ubuntu-server-2204-template-bootdisk
              namespace: default
            storage:
              resources:
                requests:
                  storage: 16Gi
      runStrategy: Halted
      template:
        metadata:
          annotations:
            vm.kubevirt.io/flavor: small
            vm.kubevirt.io/os: ubuntu
            vm.kubevirt.io/workload: server
          labels:
            kubevirt.io/domain: '${NAME}'
            kubevirt.io/size: small
        spec:
          domain:
            cpu:
              cores: 1
              sockets: 1
              threads: 1
            devices:
              disks:
                - disk:
                    bus: virtio
                  name: rootdisk
                - disk:
                    bus: virtio
                  name: cloudinitdisk
              interfaces:
                - bridge: {}
                  model: virtio
                  name: default
              networkInterfaceMultiqueue: true
              rng: {}
            features:
              acpi: {}
              smm:
                enabled: true
            firmware:
              bootloader:
                bios: {}
            machine:
              type: q35
            memory:
              guest: 2Gi
          hostname: '${NAME}'
          networks:
            - multus:
                networkName: default/vlan50
              name: default
          nodeSelector:
            network: bridge
          terminationGracePeriodSeconds: 180
          volumes:
            - name: rootdisk
              dataVolume:
                name: '${NAME}'
            - cloudInitNoCloud:
                userData: |-
                  #cloud-config
                  user: user
                  password: Password1
                  chpasswd: { expire: False }
              name: cloudinitdisk
parameters:
  - name: NAME
    description: Name for the new VM
    generate: expression
    from: 'ubuntu-2204-[a-z0-9]{16}'
    required: true

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions