Skip to content

Commit

Permalink
feat: add suffix to the s390x templates
Browse files Browse the repository at this point in the history
This change also involves renaming the templates themselves. The
end-to-end (e2e) tests require minimal adjustments.

The following templates will be generated for s390x:
- CentOS Stream 9
- Fedora
- RHEL 8
- RHEL 9
- Ubuntu

Signed-off-by: Nestor Acuna Blanco <[email protected]>
  • Loading branch information
nestoracunablanco committed Dec 2, 2024
1 parent 16d3b8d commit 6bc94e4
Show file tree
Hide file tree
Showing 19 changed files with 48 additions and 24 deletions.
3 changes: 2 additions & 1 deletion automation/test-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion automation/test_defaults.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 11 additions & 5 deletions automation/test_duplicate_templates.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 7 additions & 5 deletions generate-templates.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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}
Expand Down Expand Up @@ -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}
Expand Down Expand Up @@ -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}
Expand Down Expand Up @@ -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}
Expand Down Expand Up @@ -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}
Expand Down
5 changes: 3 additions & 2 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand All @@ -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
Expand Down
5 changes: 3 additions & 2 deletions templates/centos-stream9.tpl.yaml
Original file line number Diff line number Diff line change
@@ -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: >-
Expand Down Expand Up @@ -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}
Expand Down
1 change: 1 addition & 0 deletions templates/centos6.tpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions templates/fedora.tpl.yaml
Original file line number Diff line number Diff line change
@@ -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: >-
Expand Down Expand Up @@ -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}
Expand Down
1 change: 1 addition & 0 deletions templates/opensuse.tpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions templates/rhel7.tpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions templates/rhel8.tpl.yaml
Original file line number Diff line number Diff line change
@@ -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: >-
Expand Down Expand Up @@ -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}
Expand Down
5 changes: 3 additions & 2 deletions templates/rhel9.tpl.yaml
Original file line number Diff line number Diff line change
@@ -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: >-
Expand Down Expand Up @@ -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}
Expand Down
5 changes: 3 additions & 2 deletions templates/ubuntu.tpl.yaml
Original file line number Diff line number Diff line change
@@ -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: >-
Expand Down Expand Up @@ -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}
Expand Down
1 change: 1 addition & 0 deletions templates/windows10.tpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions templates/windows11.tpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions templates/windows2k16.tpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions templates/windows2k19.tpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions templates/windows2k22.tpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions templates/windows2k25.tpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6bc94e4

Please sign in to comment.