Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: target archictecture as a parameter #642

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
feat: target archictecture as a parameter
The default value is x86_64, but it can be overridden. This change
ensures compatibility with older versions.

Signed-off-by: Nestor Acuna Blanco <nestor.acuna@ibm.com>
nestoracunablanco committed Nov 22, 2024
commit 2fbf9636a095775e734de9176c2db7f6573e3b62
5 changes: 0 additions & 5 deletions automation/test-linux.sh
Original file line number Diff line number Diff line change
@@ -7,11 +7,6 @@ namespace="kubevirt"
ocenv="OC"
k8senv="K8s"

if [ "$TARGET" == "centos6" ] && [ "$(uname -m)" == "s390x" ]; then
echo "CentOS 6 does not support s390x."
exit 1
fi

containerdisks_url="docker://quay.io/containerdisks"
legacy_common_templates_disk_url="docker://quay.io/kubevirt/common-templates"
cnv_common_templates_url="docker://quay.io/openshift-cnv/ci-common-templates-images"
15 changes: 11 additions & 4 deletions generate-templates.yaml
Original file line number Diff line number Diff line change
@@ -3,6 +3,13 @@
hosts: 127.0.0.1
gather_facts: yes
tasks:
- name: Ensure target_arch is defined
assert:
that:
- target_arch is defined
- target_arch in ['x86_64', 's390x']
fail_msg: "Please define the target architecture as either 'x86_64' or 's390x'."

- name: Prepare dist directory
file:
path: "{{ playbook_dir }}/dist/templates"
@@ -145,7 +152,7 @@
- name: Load CentOS 6 versions
set_fact:
centos6_labels: "{{ lookup('osinfo', 'distro=centos') |map(attribute='short_id') |select('match', '^centos6\\.') |list |sort }}"
when: ansible_architecture != "s390x"
when: target_arch != "s390x"

- name: Generate CentOS 6 templates
template:
@@ -163,16 +170,16 @@
oslabels: "{{ centos6_labels }}"
osinfoname: "{{ oslabels[0] }}"
cloudusername: centos
when: ansible_architecture != "s390x"
when: target_arch != "s390x"

- name: Load Fedora versions
set_fact:
fedora_labels: "{{ lookup('osinfo', 'distro=fedora') |select('osinfo_active') |map(attribute='short_id') |select('match', '^fedora3[5-9]|^fedora[4-9][0-9]') |list |sort }}"

- name: Load Fedora containerdisk and image urls
set_fact:
fedora_containerdisk_urls: "{{ fedora_containerdisk_urls |default([]) + lookup('osinfo', item) |attr('image_list') |selectattr('architecture', 'eq', ansible_architecture) |selectattr('format', 'eq', 'containerdisk') |map(attribute='url') |map('replace', 'docker://', '') |list }}"
fedora_image_urls: "{{ fedora_image_urls |default([]) + lookup('osinfo', item) |attr('image_list') |selectattr('architecture', 'eq', ansible_architecture) |selectattr('format', 'in', ['raw', 'qcow2']) |map(attribute='url') |list }}"
fedora_containerdisk_urls: "{{ fedora_containerdisk_urls |default([]) + lookup('osinfo', item) |attr('image_list') |selectattr('architecture', 'eq', target_arch) |selectattr('format', 'eq', 'containerdisk') |map(attribute='url') |map('replace', 'docker://', '') |list }}"
fedora_image_urls: "{{ fedora_image_urls |default([]) + lookup('osinfo', item) |attr('image_list') |selectattr('architecture', 'eq', target_arch) |selectattr('format', 'in', ['raw', 'qcow2']) |map(attribute='url') |list }}"
loop: "{{ fedora_labels }}"

- name: Generate Fedora templates
5 changes: 4 additions & 1 deletion makefile
Original file line number Diff line number Diff line change
@@ -5,6 +5,9 @@ ALL_META_TEMPLATES=$(wildcard templates/*.yaml)
ALL_PRESETS=$(wildcard presets/*.yaml)
METASOURCES=$(ALL_META_TEMPLATES) $(ALL_PRESETS)

# target architecture
TARGET_ARCH?=x86_64

# Make sure the version is defined
export VERSION=$(shell ./version.sh)
export REVISION=$(shell ./revision.sh)
@@ -41,7 +44,7 @@ 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
ansible-playbook generate-templates.yaml -e "target_arch=$(TARGET_ARCH)"

update-osinfo-db:
git submodule init
4 changes: 2 additions & 2 deletions templates/fedora.tpl.yaml
Original file line number Diff line number Diff line change
@@ -95,9 +95,9 @@ objects:
kubevirt.io/domain: ${NAME}
kubevirt.io/size: {{ item.flavor }}
spec:
architecture: "{{ 'amd64' if ansible_architecture == 'x86_64' else ansible_architecture }}"
architecture: "{{ 'amd64' if target_arch == 'x86_64' else target_arch }}"
domain:
{% if ansible_architecture != 's390x' %}
{% if target_arch != 's390x' %}
features:
smm:
enabled: true