Fedora Account System
Red Hat Associate
Red Hat Customer
Description of problem: template validator currently uses annotations for validation. Based on the documentation (https://github.com/kubevirt/common-templates/tree/master/templates), the validation should be done based on labels, so the validator should be fixed to check under labels. Version-Release number of selected component (if applicable): How reproducible: 100% Steps to Reproduce: 1. Create a template file with template name and namespace under labels - template.yaml apiVersion: template.openshift.io/v1 kind: Template metadata: annotations: defaults.template.kubevirt.io/disk: rootdisk description: This template can be used to create a VM suitable for Red Hat Enterprise Linux 7 and newer. The template assumes that a PVC is available which is providing the necessary RHEL disk image. iconClass: icon-rhel name.os.template.kubevirt.io/rhel7.0: Red Hat Enterprise Linux 7.0 name.os.template.kubevirt.io/rhel7.1: Red Hat Enterprise Linux 7.1 name.os.template.kubevirt.io/rhel7.2: Red Hat Enterprise Linux 7.2 name.os.template.kubevirt.io/rhel7.3: Red Hat Enterprise Linux 7.3 name.os.template.kubevirt.io/rhel7.4: Red Hat Enterprise Linux 7.4 name.os.template.kubevirt.io/rhel7.5: Red Hat Enterprise Linux 7.5 name.os.template.kubevirt.io/rhel7.6: Red Hat Enterprise Linux 7.6 openshift.io/display-name: Red Hat Enterprise Linux 7.0+ VM openshift.io/documentation-url: https://github.com/kubevirt/common-templates openshift.io/provider-display-name: KubeVirt openshift.io/support-url: https://github.com/kubevirt/common-templates/issues tags: kubevirt,virtualmachine,linux,rhel template.kubevirt.io/editable: | /objects[0].spec.template.spec.domain.cpu.sockets /objects[0].spec.template.spec.domain.cpu.cores /objects[0].spec.template.spec.domain.cpu.threads /objects[0].spec.template.spec.domain.resources.requests.memory /objects[0].spec.template.spec.domain.devices.disks /objects[0].spec.template.spec.volumes /objects[0].spec.template.spec.networks template.kubevirt.io/version: v1alpha1 template.openshift.io/bindable: "false" validations: | [ { "name": "minimal-required-memory", "path": "jsonpath::.spec.domain.resources.requests.memory", "rule": "integer", "message": "This VM requires more memory.", "min": 2147483648 }, ] creationTimestamp: 2019-09-19T13:00:03Z labels: flavor.template.kubevirt.io/tiny: "true" os.template.kubevirt.io/rhel7.0: "true" os.template.kubevirt.io/rhel7.1: "true" os.template.kubevirt.io/rhel7.2: "true" os.template.kubevirt.io/rhel7.3: "true" os.template.kubevirt.io/rhel7.4: "true" os.template.kubevirt.io/rhel7.5: "true" os.template.kubevirt.io/rhel7.6: "true" template.kubevirt.io/type: base workload.template.kubevirt.io/server: "true" name: rhel7-server-tiny-tmp namespace: openshift ownerReferences: - apiVersion: kubevirt.io/v1 kind: KubevirtCommonTemplatesBundle name: common-templates-hyperconverged-cluster uid: 4d7cdf30-da31-11e9-9cda-fa163ec431b1 resourceVersion: "900825" selfLink: /apis/template.openshift.io/v1/namespaces/openshift/templates/rhel7-server-tiny-tmp uid: 6594840c-dadd-11e9-a3fd-0a580a80002d objects: - apiVersion: kubevirt.io/v1alpha3 kind: VirtualMachine metadata: labels: app: ${NAME} vm.kubevirt.io/template: rhel7-server-tiny-tmp vm.kubevirt.io/template-namespace: openshift vm.kubevirt.io/template.revision: "1" vm.kubevirt.io/template.version: v0.6.2 name: ${NAME} spec: running: false template: metadata: labels: kubevirt.io/domain: ${NAME} kubevirt.io/size: tiny spec: domain: cpu: cores: 1 sockets: 1 threads: 1 devices: disks: - disk: bus: virtio name: rootdisk - disk: bus: virtio name: cloudinitdisk interfaces: - bridge: {} name: default rng: {} resources: requests: memory: 1G evictionStrategy: LiveMigrate networks: - name: default pod: {} terminationGracePeriodSeconds: 0 volumes: - name: rootdisk persistentVolumeClaim: claimName: ${PVCNAME} - cloudInitNoCloud: userData: |- #cloud-config password: redhat chpasswd: { expire: False } name: cloudinitdisk parameters: - description: VM name from: rhel7-[a-z0-9]{16} generate: expression name: NAME - description: Name of the PVC with the disk image name: PVCNAME required: true 2. Create the template oc create -f template.yaml -n openshift 3. Create a DV - oc create -f rhel-dv.yaml apiVersion: cdi.kubevirt.io/v1alpha1 kind: DataVolume metadata: name: rhel7 spec: source: http: url: "http://cnv-qe-server.rhevdev.lab.eng.rdu2.redhat.com/files/rhel-images/rhel-76/rhel-76.qcow2" pvc: accessModes: - ReadWriteOnce resources: requests: storage: "25Gi" 4. Create a VM which uses the template and the pvc oc process -n openshift rhel7-server-tiny-tmp -p NAME="test8" -p PVCNAME="rhel7" | oc create -n default -f - Actual results: VM is created Expected results: VM creation should fail (memory validation should fail) Additional info:
Fixed upstream in https://github.com/fromanirh/kubevirt-template-validator/pull/29
please add fixed in version
Verified on CNV 2.2.0. 1. Created a template with `vm.kubevirt.io/template` and `vm.kubevirt.io/template.namespace` under metadata-> labels 2. Created a template with `vm.kubevirt.io/template` and `vm.kubevirt.io/template.namespace` under metadata-> annotations 3. Delete both 4. Add both The UI only provides templates which are in the same namespace as the created VM - template is found, validations checked.
closing this bug manually; it should have been included in https://access.redhat.com/errata/RHEA-2020:0307