diff --git a/automation/test-linux.sh b/automation/test-linux.sh index ccf8d74e..ff4b7aeb 100755 --- a/automation/test-linux.sh +++ b/automation/test-linux.sh @@ -163,9 +163,10 @@ run_vm() { fi } +target_arch_suffix=$( [ "$TARGET_ARCH" = "x86_64" ] && echo "" || echo "-$TARGET_ARCH" ) for size in "${sizes[@]}"; do for workload in "${workloads[@]}"; do - vm_name=$template_name-$workload-$size + vm_name=$template_name-$workload-$size$target_arch_suffix run_vm "$vm_name" done done diff --git a/automation/test_defaults.sh b/automation/test_defaults.sh index c53362e7..b494de02 100755 --- a/automation/test_defaults.sh +++ b/automation/test_defaults.sh @@ -46,7 +46,7 @@ for os in "${oss[@]}"; do continue fi - defaults=$(oc get template -l "$os,template.kubevirt.io/default-os-variant = true,$ver_label" -o name | wc -l) + defaults=$(oc get template -l "$os,template.kubevirt.io/default-os-variant = true,$ver_label,template.kubevirt.io/architecture=amd64" -o name | wc -l) if [[ $defaults -eq 1 ]]; then continue diff --git a/automation/test_duplicate_templates.sh b/automation/test_duplicate_templates.sh index 5aa2a621..1a4742a4 100755 --- a/automation/test_duplicate_templates.sh +++ b/automation/test_duplicate_templates.sh @@ -39,15 +39,21 @@ for template in "${templates[@]}"; do yq -o props '.metadata.labels | with_entries(select(.key == "flavor.template.kubevirt.io/*"))' "$template" \ ) + readarray -t template_archs < <( \ + yq -o props '.metadata.labels | with_entries(select(.key == "template.kubevirt.io/architecture"))' "$template" \ + ) + for os in "${template_oss[@]}"; do for workload in "${template_workloads[@]}"; do for flavor in "${template_flavors[@]}"; do - count=$(oc get template -l "$os,$workload,$flavor,$ver_label" --no-headers | wc -l) + for architecture in "${template_archs[@]}"; do + count=$(oc get template -l "$os,$workload,$flavor,$ver_label,$architecture" --no-headers | wc -l) - if [[ $count -ne 1 ]]; then - echo "There are $count templates found with the following labels $os,$workload,$flavor,$ver_label" - exit 1 - fi + if [[ $count -ne 1 ]]; then + echo "There are $count templates found with the following labels $os,$workload,$flavor,$ver_label,$architecture" + exit 1 + fi + done done done done diff --git a/generate-templates.yaml b/generate-templates.yaml index 042443ea..40d2f8ea 100644 --- a/generate-templates.yaml +++ b/generate-templates.yaml @@ -2,6 +2,8 @@ - connection: local hosts: 127.0.0.1 gather_facts: yes + vars: + suffix: "{{ '' if target_arch == 'x86_64' else '-' + target_arch }}" tasks: - name: Ensure target_arch is defined assert: @@ -27,7 +29,7 @@ - name: Generate RHEL 9 templates template: src: rhel9.tpl.yaml - dest: "{{ playbook_dir }}/dist/templates/{{ os }}-{{ item.workload }}-{{ item.flavor }}.yaml" + dest: "{{ playbook_dir }}/dist/templates/{{ os }}-{{ item.workload }}-{{ item.flavor }}{{ suffix }}.yaml" with_items: - {flavor: tiny, workload: server, memsize: "1.5Gi", cpus: 1, iothreads: False, emulatorthread: False, tablet: False, default: False} - {flavor: tiny, workload: desktop, memsize: "1.5Gi", cpus: 1, iothreads: False, emulatorthread: False, tablet: True, default: False} @@ -62,7 +64,7 @@ - name: Generate RHEL 8 templates template: src: rhel8.tpl.yaml - dest: "{{ playbook_dir }}/dist/templates/{{ os }}-{{ item.workload }}-{{ item.flavor }}.yaml" + dest: "{{ playbook_dir }}/dist/templates/{{ os }}-{{ item.workload }}-{{ item.flavor }}{{ suffix }}.yaml" with_items: - {flavor: tiny, workload: server, memsize: "1.5Gi", cpus: 1, iothreads: False, emulatorthread: False, tablet: False, default: False} - {flavor: tiny, workload: desktop, memsize: "1.5Gi", cpus: 1, iothreads: False, emulatorthread: False, tablet: True, default: False} @@ -131,7 +133,7 @@ - name: Generate CentOS Stream 9 templates template: src: centos-stream9.tpl.yaml - dest: "{{ playbook_dir }}/dist/templates/{{ os }}-{{ item.workload }}-{{ item.flavor }}.yaml" + dest: "{{ playbook_dir }}/dist/templates/{{ os }}-{{ item.workload }}-{{ item.flavor }}{{ suffix }}.yaml" with_items: - {flavor: tiny, workload: server, memsize: "1.5Gi", cpus: 1, iothreads: False, emulatorthread: False, tablet: False, default: False} - {flavor: tiny, workload: desktop, memsize: "1.5Gi", cpus: 1, iothreads: False, emulatorthread: False, tablet: True, default: False} @@ -188,7 +190,7 @@ - name: Generate Fedora templates template: src: fedora.tpl.yaml - dest: "{{ playbook_dir }}/dist/templates/{{ os }}-{{ item.workload }}-{{ item.flavor }}.yaml" + dest: "{{ playbook_dir }}/dist/templates/{{ os }}-{{ item.workload }}-{{ item.flavor }}{{ suffix }}.yaml" with_items: - {flavor: small, workload: desktop, memsize: "2Gi", cpus: 1, iothreads: False, emulatorthread: False, tablet: True, default: False} - {flavor: small, workload: server, memsize: "2Gi", cpus: 1, iothreads: False, emulatorthread: False, tablet: False, default: True} @@ -252,7 +254,7 @@ - name: Generate Ubuntu templates template: src: ubuntu.tpl.yaml - dest: "{{ playbook_dir }}/dist/templates/{{ os }}-{{ item.workload }}-{{ item.flavor }}.yaml" + dest: "{{ playbook_dir }}/dist/templates/{{ os }}-{{ item.workload }}-{{ item.flavor }}{{ suffix }}.yaml" with_items: - {flavor: small, workload: desktop, memsize: "3Gi", cpus: 1, iothreads: False, emulatorthread: False, tablet: True, default: False} - {flavor: small, workload: server, memsize: "3Gi", cpus: 1, iothreads: False, emulatorthread: False, tablet: True, default: True} diff --git a/makefile b/makefile index 01c41be6..f29183bc 100644 --- a/makefile +++ b/makefile @@ -30,7 +30,7 @@ release: dist/common-templates.yaml cp dist/common-templates.yaml dist/common-templates-$(VERSION).yaml e2e-tests: - ./automation/test.sh + TARGET_ARCH=$(TARGET_ARCH) ./automation/test.sh go-tests: go test -v ./tests/ @@ -44,7 +44,8 @@ validate-no-offensive-lang: generate: generate-templates.yaml $(METASOURCES) # Just build the XML files, no need to export to tarball make -C osinfo-db/ OSINFO_DB_EXPORT=echo - ansible-playbook generate-templates.yaml -e "target_arch=$(TARGET_ARCH)" + ansible-playbook generate-templates.yaml -e "target_arch=x86_64" + ansible-playbook generate-templates.yaml -e "target_arch=s390x" update-osinfo-db: git submodule init diff --git a/templates/centos-stream9.tpl.yaml b/templates/centos-stream9.tpl.yaml index f03674c0..3a0a73a6 100644 --- a/templates/centos-stream9.tpl.yaml +++ b/templates/centos-stream9.tpl.yaml @@ -1,7 +1,7 @@ apiVersion: template.openshift.io/v1 kind: Template metadata: - name: {{ os }}-{{ item.workload }}-{{ item.flavor }} + name: {{ os }}-{{ item.workload }}-{{ item.flavor }}{{ suffix }} annotations: openshift.io/display-name: "CentOS Stream 9 VM" description: >- @@ -49,13 +49,14 @@ metadata: {% if item.default %} template.kubevirt.io/default-os-variant: "true" {% endif %} + template.kubevirt.io/architecture: "{{ 'amd64' if target_arch == 'x86_64' else target_arch }}" objects: - apiVersion: kubevirt.io/v1 kind: VirtualMachine metadata: name: ${NAME} labels: - vm.kubevirt.io/template: {{ os }}-{{ item.workload }}-{{ item.flavor }} + vm.kubevirt.io/template: {{ os }}-{{ item.workload }}-{{ item.flavor }}{{ suffix }} vm.kubevirt.io/template.version: "{{ lookup('env', 'VERSION') | default('devel', true) }}" vm.kubevirt.io/template.revision: "{{ lookup('env', 'REVISION') | default(1, true) }}" app: ${NAME} diff --git a/templates/centos6.tpl.yaml b/templates/centos6.tpl.yaml index 6317c471..b6fe4026 100644 --- a/templates/centos6.tpl.yaml +++ b/templates/centos6.tpl.yaml @@ -39,6 +39,7 @@ metadata: {% if item.default %} template.kubevirt.io/default-os-variant: "true" {% endif %} + template.kubevirt.io/architecture: "amd64" objects: - apiVersion: kubevirt.io/v1 kind: VirtualMachine diff --git a/templates/fedora.tpl.yaml b/templates/fedora.tpl.yaml index 06c469e4..32026417 100644 --- a/templates/fedora.tpl.yaml +++ b/templates/fedora.tpl.yaml @@ -1,7 +1,7 @@ apiVersion: template.openshift.io/v1 kind: Template metadata: - name: {{ os }}-{{ item.workload }}-{{ item.flavor }} + name: {{ os }}-{{ item.workload }}-{{ item.flavor }}{{ suffix }} annotations: openshift.io/display-name: "Fedora VM" description: >- @@ -48,13 +48,14 @@ metadata: {% if item.default %} template.kubevirt.io/default-os-variant: "true" {% endif %} + template.kubevirt.io/architecture: "{{ 'amd64' if target_arch == 'x86_64' else target_arch }}" objects: - apiVersion: kubevirt.io/v1 kind: VirtualMachine metadata: name: ${NAME} labels: - vm.kubevirt.io/template: {{ os }}-{{ item.workload }}-{{ item.flavor }} + vm.kubevirt.io/template: {{ os }}-{{ item.workload }}-{{ item.flavor }}{{ suffix }} vm.kubevirt.io/template.version: "{{ lookup('env', 'VERSION') | default('devel', true) }}" vm.kubevirt.io/template.revision: "{{ lookup('env', 'REVISION') | default(1, true) }}" app: ${NAME} diff --git a/templates/opensuse.tpl.yaml b/templates/opensuse.tpl.yaml index 27f26dd7..c8f61637 100644 --- a/templates/opensuse.tpl.yaml +++ b/templates/opensuse.tpl.yaml @@ -43,6 +43,7 @@ metadata: {% if item.default %} template.kubevirt.io/default-os-variant: "true" {% endif %} + template.kubevirt.io/architecture: "amd64" objects: - apiVersion: kubevirt.io/v1 kind: VirtualMachine diff --git a/templates/rhel7.tpl.yaml b/templates/rhel7.tpl.yaml index 46d14124..0bbe18f2 100644 --- a/templates/rhel7.tpl.yaml +++ b/templates/rhel7.tpl.yaml @@ -43,6 +43,7 @@ metadata: {% if item.default %} template.kubevirt.io/default-os-variant: "true" {% endif %} + template.kubevirt.io/architecture: "amd64" objects: - apiVersion: kubevirt.io/v1 kind: VirtualMachine diff --git a/templates/rhel8.tpl.yaml b/templates/rhel8.tpl.yaml index dc2ee5a8..e1ebbe3d 100644 --- a/templates/rhel8.tpl.yaml +++ b/templates/rhel8.tpl.yaml @@ -1,7 +1,7 @@ apiVersion: template.openshift.io/v1 kind: Template metadata: - name: {{ os }}-{{ item.workload }}-{{ item.flavor }} + name: {{ os }}-{{ item.workload }}-{{ item.flavor }}{{ suffix }} annotations: openshift.io/display-name: "Red Hat Enterprise Linux 8 VM" description: >- @@ -45,13 +45,14 @@ metadata: {% if item.default %} template.kubevirt.io/default-os-variant: "true" {% endif %} + template.kubevirt.io/architecture: "{{ 'amd64' if target_arch == 'x86_64' else target_arch }}" objects: - apiVersion: kubevirt.io/v1 kind: VirtualMachine metadata: name: ${NAME} labels: - vm.kubevirt.io/template: {{ os }}-{{ item.workload }}-{{ item.flavor }} + vm.kubevirt.io/template: {{ os }}-{{ item.workload }}-{{ item.flavor }}{{ suffix }} vm.kubevirt.io/template.version: "{{ lookup('env', 'VERSION') | default('devel', true) }}" vm.kubevirt.io/template.revision: "{{ lookup('env', 'REVISION') | default(1, true) }}" app: ${NAME} diff --git a/templates/rhel9.tpl.yaml b/templates/rhel9.tpl.yaml index 1cf00a53..f013c12e 100644 --- a/templates/rhel9.tpl.yaml +++ b/templates/rhel9.tpl.yaml @@ -1,7 +1,7 @@ apiVersion: template.openshift.io/v1 kind: Template metadata: - name: {{ os }}-{{ item.workload }}-{{ item.flavor }} + name: {{ os }}-{{ item.workload }}-{{ item.flavor }}{{ suffix }} annotations: openshift.io/display-name: "Red Hat Enterprise Linux 9 VM" description: >- @@ -45,13 +45,14 @@ metadata: {% if item.default %} template.kubevirt.io/default-os-variant: "true" {% endif %} + template.kubevirt.io/architecture: "{{ 'amd64' if target_arch == 'x86_64' else target_arch }}" objects: - apiVersion: kubevirt.io/v1 kind: VirtualMachine metadata: name: ${NAME} labels: - vm.kubevirt.io/template: {{ os }}-{{ item.workload }}-{{ item.flavor }} + vm.kubevirt.io/template: {{ os }}-{{ item.workload }}-{{ item.flavor }}{{ suffix }} vm.kubevirt.io/template.version: "{{ lookup('env', 'VERSION') | default('devel', true) }}" vm.kubevirt.io/template.revision: "{{ lookup('env', 'REVISION') | default(1, true) }}" app: ${NAME} diff --git a/templates/ubuntu.tpl.yaml b/templates/ubuntu.tpl.yaml index 60d238c4..bc2649fb 100644 --- a/templates/ubuntu.tpl.yaml +++ b/templates/ubuntu.tpl.yaml @@ -1,7 +1,7 @@ apiVersion: template.openshift.io/v1 kind: Template metadata: - name: {{ os }}-{{ item.workload }}-{{ item.flavor }} + name: {{ os }}-{{ item.workload }}-{{ item.flavor }}{{ suffix }} annotations: openshift.io/display-name: "Ubuntu {{ lookup('osinfo', oslabels[0]).version }}+ VM" description: >- @@ -49,13 +49,14 @@ metadata: {% if item.default %} template.kubevirt.io/default-os-variant: "true" {% endif %} + template.kubevirt.io/architecture: "{{ 'amd64' if target_arch == 'x86_64' else target_arch }}" objects: - apiVersion: kubevirt.io/v1 kind: VirtualMachine metadata: name: ${NAME} labels: - vm.kubevirt.io/template: {{ os }}-{{ item.workload }}-{{ item.flavor }} + vm.kubevirt.io/template: {{ os }}-{{ item.workload }}-{{ item.flavor }}{{ suffix }} vm.kubevirt.io/template.version: "{{ lookup('env', 'VERSION') | default('devel', true) }}" vm.kubevirt.io/template.revision: "{{ lookup('env', 'REVISION') | default(1, true) }}" app: ${NAME} diff --git a/templates/windows10.tpl.yaml b/templates/windows10.tpl.yaml index f0c908fb..88b45d79 100644 --- a/templates/windows10.tpl.yaml +++ b/templates/windows10.tpl.yaml @@ -32,6 +32,7 @@ metadata: {% if item.default %} template.kubevirt.io/default-os-variant: "true" {% endif %} + template.kubevirt.io/architecture: "amd64" objects: - apiVersion: kubevirt.io/v1 kind: VirtualMachine diff --git a/templates/windows11.tpl.yaml b/templates/windows11.tpl.yaml index 8f1bd1cc..a7c5be4f 100644 --- a/templates/windows11.tpl.yaml +++ b/templates/windows11.tpl.yaml @@ -32,6 +32,7 @@ metadata: {% if item.default %} template.kubevirt.io/default-os-variant: "true" {% endif %} + template.kubevirt.io/architecture: "amd64" objects: - apiVersion: kubevirt.io/v1 kind: VirtualMachine diff --git a/templates/windows2k16.tpl.yaml b/templates/windows2k16.tpl.yaml index 5e5c569c..7af6c7ab 100644 --- a/templates/windows2k16.tpl.yaml +++ b/templates/windows2k16.tpl.yaml @@ -32,6 +32,7 @@ metadata: {% if item.default %} template.kubevirt.io/default-os-variant: "true" {% endif %} + template.kubevirt.io/architecture: "amd64" objects: - apiVersion: kubevirt.io/v1 kind: VirtualMachine diff --git a/templates/windows2k19.tpl.yaml b/templates/windows2k19.tpl.yaml index 3f553841..8fec488a 100644 --- a/templates/windows2k19.tpl.yaml +++ b/templates/windows2k19.tpl.yaml @@ -32,6 +32,7 @@ metadata: {% if item.default %} template.kubevirt.io/default-os-variant: "true" {% endif %} + template.kubevirt.io/architecture: "amd64" objects: - apiVersion: kubevirt.io/v1 kind: VirtualMachine diff --git a/templates/windows2k22.tpl.yaml b/templates/windows2k22.tpl.yaml index 316fe91b..20faf4f1 100644 --- a/templates/windows2k22.tpl.yaml +++ b/templates/windows2k22.tpl.yaml @@ -32,6 +32,7 @@ metadata: {% if item.default %} template.kubevirt.io/default-os-variant: "true" {% endif %} + template.kubevirt.io/architecture: "amd64" objects: - apiVersion: kubevirt.io/v1 kind: VirtualMachine diff --git a/templates/windows2k25.tpl.yaml b/templates/windows2k25.tpl.yaml index 44377fa7..6c1675e3 100644 --- a/templates/windows2k25.tpl.yaml +++ b/templates/windows2k25.tpl.yaml @@ -32,6 +32,7 @@ metadata: {% if item.default %} template.kubevirt.io/default-os-variant: "true" {% endif %} + template.kubevirt.io/architecture: "amd64" objects: - apiVersion: kubevirt.io/v1 kind: VirtualMachine