Uploaded image for project: 'OpenShift Virtualization'
  1. OpenShift Virtualization
  2. CNV-42852

Creating VM from custom Boot Source writes cloud-init config with "fedora" username for all kinds of OS

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Normal Normal
    • CNV v4.17.0
    • CNV v4.15.2
    • CNV User Interface
    • None
    • 0.42
    • False
    • Hide

      None

      Show
      None
    • False
    • CNV v4.17.0.rhel9-60
    • ---
    • ---
    • Medium
    • No

      Description of problem:

      Creating a custom Bootable Source for using with a custom Preference makes the system fail to properly identify the OS, and defaulting to "fedora" for the generated cloud-init config.
      
      It seems to identify the OS based on the VMCP name, I'm not able to find any annotation or spec to define/override the OS. 
      
      Also, doesn't seem to find OS as per osinfo short-ids if I create a VMP named after  it. Tried using labels and annotations as well, nothing really works to tell it the OS so that it doesn't default to "fedora" for cloud-init user.
      
      The issue below is reproducible for RHEL, Ubuntu, Debian, CentOS or anything that doesn't use fedora as the default cloud-init username.
      
      

      Version-Release number of selected component (if applicable):

      CNV 4.15.2

      How reproducible:

      Always

      Steps to Reproduce:

      1. Create a new Preference, for example this one which is essentially a copy of the cluster default rhel.7 one, except with a different name, germano-rhel-7.9 in this case.

      apiVersion: instancetype.kubevirt.io/v1beta1
      kind: VirtualMachinePreference
      metadata:
        annotations:
          iconClass: icon-rhel
          openshift.io/display-name: Red Hat Enterprise Linux 7
          openshift.io/documentation-url: https://access.redhat.com
          openshift.io/provider-display-name: Red Hat
          openshift.io/support-url: https://access.redhat.com
          operator-sdk/primary-resource: openshift-cnv/ssp-kubevirt-hyperconverged
          operator-sdk/primary-resource-type: SSP.ssp.kubevirt.io
          tags: hidden,kubevirt,linux,rhel
        creationTimestamp: "2024-06-10T00:32:51Z"
        generation: 1
        labels:
          app.kubernetes.io/component: templating
          app.kubernetes.io/managed-by: ssp-operator
          app.kubernetes.io/name: common-instancetypes
          app.kubernetes.io/part-of: hyperconverged-cluster
          app.kubernetes.io/version: 4.15.2
          instancetype.kubevirt.io/common-instancetypes-version: 0.4.1-7-g343ce23
          instancetype.kubevirt.io/os-type: linux
          instancetype.kubevirt.io/vendor: redhat.com
        name: germano-rhel-7.9
        namespace: openshift-virtualization-os-images
        resourceVersion: "390086"
        uid: 9daf9cfa-6eb5-42fa-9a06-d7a14c3a453d
      spec:
        devices:
          preferredDiskBus: virtio
          preferredInterfaceModel: virtio
        requirements:
          cpu:
            guest: 1
          memory:
            guest: 1Gi 
      
      

      2. Create a new DV and DS pointing to this preference

      apiVersion: cdi.kubevirt.io/v1beta1
      kind: DataSource
      metadata:
        labels:
          instancetype.kubevirt.io/default-instancetype: u1.medium
          instancetype.kubevirt.io/default-preference: germano-rhel.7.9
      spec:
        source:
          pvc:
            name: rhel79
            namespace: openshift-virtualization-os-images
      status:
        conditions:
          - lastHeartbeatTime: '2024-06-09T23:36:14Z'
            lastTransitionTime: '2024-06-09T23:36:14Z'
            message: DataSource is ready to be consumed
            reason: Ready
            status: 'True'
            type: Ready
        source:
          pvc:
            name: rhel79
            namespace: openshift-virtualization-os-images
       

      3. Go in the UI, and create a new VM based on that bootable volume. You don't even need to create it, just preview the YAML and scrown down to find "fedora" in the cloud-init username.

       Actual results:

      The generated cloud init has fedora user-name on it:

              - cloudInitNoCloud:
                  userData: |
                    #cloud-config
                    chpasswd:
                      expire: false
                    password: kvu8-ivwe-q8u0
                    user: fedora
       

      Expected results:

      The generated cloud init has the default username for the OS as specified by libosinfo and not "fedora" for everything that doesn't match the default names.

      osinfo-db % grep -rin cloud-image-username        
      ./data/schema/osinfo.rng.in:646:          <element name="cloud-image-username">
      ./data/os/rockylinux.org/rocky-9.xml.in:319:    <cloud-image-username>rocky</cloud-image-username>
      ./data/os/rockylinux.org/rocky-8.xml.in:190:    <cloud-image-username>rocky</cloud-image-username>
      ./data/os/almalinux.org/almalinux-9.xml.in:349:    <cloud-image-username>almalinux</cloud-image-username>
      ./data/os/almalinux.org/almalinux-8.xml.in:293:    <cloud-image-username>almalinux</cloud-image-username>
      ./data/os/ubuntu.com/ubuntu-16.04.xml.in:152:    <cloud-image-username>ubuntu</cloud-image-username>
      ./data/os/fedoraproject.org/fedora-28.xml.in:135:    <cloud-image-username>fedora</cloud-image-username>
      ./data/os/altlinux.org/alt-p11.starterkits.xml.in:63:    <cloud-image-username>altlinux</cloud-image-username>
      ./data/os/altlinux.org/alt-p9.starterkits.xml.in:60:    <cloud-image-username>altlinux</cloud-image-username>
      ./data/os/altlinux.org/alt-p10.starterkits.xml.in:60:    <cloud-image-username>altlinux</cloud-image-username>
      ./data/os/debian.org/debian-9.xml.in:190:    <cloud-image-username>debian</cloud-image-username>
      ./data/os/centos.org/centos-7.0.xml.in:650:    <cloud-image-username>centos</cloud-image-username>
       

            mschatzm@redhat.com Matan Schatzman
            rhn-support-gveitmic Germano Veit Michel
            Guohua Ouyang Guohua Ouyang
            Votes:
            1 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated: