From 7f2e6f3325c762fb678cf9da7a34af8467e11e22 Mon Sep 17 00:00:00 2001 From: Ian Wienand Date: Thu, 18 Jan 2024 11:01:39 +1100 Subject: [PATCH] roles/openafs-client: small overhaul of rpm builds The main failure case for the openafs packages is when the images are running an old kernel and upstream has moved on, and we only have headers available for new kernels. This usually indicates image building is stuck. This adds an inline check to make sure the running kernel has headers available; if not it bails out with a clear message. When this does fail to build, we'd like to get some output of why the service fails. This adds an error handler to systemctl dump the status on failure. We can cleanup the build a bit to remove the centos7 builds now. Finally, the log copying was broken -- the paths are different on centos 8 and 9. The extant "cp" would fail on centos8 and then the chown would never run, so we wouldn't collect the build logs. Make this a find/cp pair too. Change-Id: Iaa38357a8a683a474c38900f5dc322e088849416 --- roles-test/post.yaml | 7 ++- roles/openafs-client/tasks/main.yaml | 16 ++++-- .../tasks/openafs-client/CentOS.yaml | 50 ++++++++++--------- 3 files changed, 41 insertions(+), 32 deletions(-) diff --git a/roles-test/post.yaml b/roles-test/post.yaml index 14bfe0fb6f..c7f42ee080 100644 --- a/roles-test/post.yaml +++ b/roles-test/post.yaml @@ -13,11 +13,10 @@ shell: | DKMS_MAKE_LOGS=/var/lib/dkms-make-logs mkdir ${DKMS_MAKE_LOGS} - # NOTE(ianw) 2023-04-27 This follwoing find may be redundant - # now; it does not seem to match anything on centos 9-stream - # at least. + # pre ~ 9-stream find /var/lib/dkms/ -type d -wholename "*/log" -exec cp -r --parents \{\} ${DKMS_MAKE_LOGS} \; - cp /var/lib/dkms/openafs/*/build/make.log ${DKMS_MAKE_LOGS} + # >= 9-stream + find /var/lib/dkms/ -type d -wholename "*/build" -exec cp -r --parents \{\} ${DKMS_MAKE_LOGS} \; chown zuul:zuul ${DKMS_MAKE_LOGS} become: yes - include_role: diff --git a/roles/openafs-client/tasks/main.yaml b/roles/openafs-client/tasks/main.yaml index 6ed5412f7c..89ff0e21ae 100644 --- a/roles/openafs-client/tasks/main.yaml +++ b/roles/openafs-client/tasks/main.yaml @@ -91,8 +91,14 @@ - openafs-client - name: Ensure openafs-client service running - service: - name: openafs-client - state: started - enabled: yes - become: yes + block: + - name: Start service + service: + name: openafs-client + state: started + enabled: yes + become: yes + rescue: + - name: Dump service status + command: systemctl status openafs-client.service + become: yes diff --git a/roles/openafs-client/tasks/openafs-client/CentOS.yaml b/roles/openafs-client/tasks/openafs-client/CentOS.yaml index 6784fcdfe5..dcffb6394f 100644 --- a/roles/openafs-client/tasks/openafs-client/CentOS.yaml +++ b/roles/openafs-client/tasks/openafs-client/CentOS.yaml @@ -28,34 +28,38 @@ gpgcheck: '{{ openafs_client_yum_repo_gpg_check }}' become: yes -- name: Install kernel modules CentOS 7 - yum: - name: - - kernel-devel - - dkms - - gcc - - dkms-openafs - enablerepo: epel # dkms - state: present - become: yes - when: ansible_distribution_version is version('8', '<') - -- name: Install kernel modules CentOS 8 +- name: Install kernel dev packages dnf: name: - kernel-devel - - dkms - gcc + - make + - dkms + enablerepo: epel # dkms + state: latest + become: yes + +- name: Compare installed headers v running kernel + shell: | + cur=$(uname -r) + rpm=$(rpm -qP kernel-devel | grep uname) + if ! echo ${rpm} | grep -q ${cur}; then + echo "*** Running kernel does not have headers" + echo "cur=${cur}" + echo "kernels" + rpm -qP kernel-devel | grep uname + exit 1 + else + echo "Headers look OK" + fi + +- name: Install openafs kernel modules + dnf: + name: + - openafs + - openafs-krb5 + - openafs-client - dkms-openafs enablerepo: epel # dkms state: present become: yes - when: ansible_distribution_version is version('8', '>=') - -- name: Install client - yum: - name: - - openafs-krb5 - - openafs-client - state: present - become: yes