From: Luis Chamberlain <mcgrof@kernel.org>
To: Chuck Lever <cel@kernel.org>, Daniel Gomez <da.gomez@kruces.com>,
kdevops@lists.linux.dev
Cc: Luis Chamberlain <mcgrof@kernel.org>
Subject: [RFT 4/4] guestfs: fix checksum verification for resized custom images
Date: Tue, 26 Aug 2025 20:57:47 -0700 [thread overview]
Message-ID: <20250827035747.3314144-5-mcgrof@kernel.org> (raw)
In-Reply-To: <20250827035747.3314144-1-mcgrof@kernel.org>
The SHA512 checksum verification was failing because it was being run
after the image had been resized and modified. The checksum from the
upstream source is only valid for the original downloaded image, not
the modified version.
Fix by:
1. Verifying the checksum immediately after download, before any
modifications
2. Removing the redundant checksum verification that happened after
resize operations
This ensures the image integrity is verified when downloaded, but
doesn't fail on subsequent runs when the image has been customized
for kdevops use.
Error was:
sha512sum: WARNING: 1 computed checksum did NOT match
debian-13-generic-amd64-daily.raw: FAILED
Generated-by: Claude AI
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
.../roles/base_image/tasks/custom-image.yml | 57 ++++++++-----------
1 file changed, 24 insertions(+), 33 deletions(-)
diff --git a/playbooks/roles/base_image/tasks/custom-image.yml b/playbooks/roles/base_image/tasks/custom-image.yml
index a3a8cbbd..d23cce96 100644
--- a/playbooks/roles/base_image/tasks/custom-image.yml
+++ b/playbooks/roles/base_image/tasks/custom-image.yml
@@ -46,6 +46,29 @@
- not custom_image_stat.stat.exists
- guestfs_has_custom_raw_image_url|bool
+- name: Verify custom image checksum immediately after download
+ when:
+ - custom_image_download is changed
+ - guestfs_has_custom_raw_image_sha512sums|bool
+ block:
+ - name: Get the base name of the sha512sums file for verification
+ ansible.builtin.set_fact:
+ sha512sums_file: "{{ guestfs_custom_raw_image_sha512sums_url | basename }}"
+
+ - name: Fetch the sha512sums file for verification
+ become: true
+ become_method: ansible.builtin.sudo
+ ansible.builtin.get_url:
+ url: "{{ guestfs_custom_raw_image_sha512sums_url }}"
+ dest: "{{ custom_image_dir }}"
+ mode: "u=rw,g=r,o=r"
+
+ - name: Verify checksum of freshly downloaded image
+ ansible.builtin.command:
+ cmd: "sha512sum --ignore-missing -c {{ sha512sums_file }}"
+ chdir: "{{ custom_image_dir }}"
+ changed_when: false
+
- name: Resize custom image to match configured size
become: true
become_method: ansible.builtin.sudo
@@ -104,42 +127,10 @@
get_mime: false
register: sentinel_stat
-- name: Check the custom image
+- name: Configure custom image with kdevops settings
when:
- not sentinel_stat.stat.exists
- - guestfs_has_custom_raw_image_sha512sums|bool
block:
- - name: Get the base name of the sha512sums file
- ansible.builtin.set_fact:
- sha512sums_file: "{{ guestfs_custom_raw_image_sha512sums_url | basename }}"
-
- - name: Set the full pathname of sha512sums file
- ansible.builtin.set_fact:
- custom_image_sha512sum: "{{ custom_image_dir }}/{{ sha512sums_file }}"
-
- - name: Check if the sha512sums file already exists
- ansible.builtin.stat:
- path: "{{ custom_image_sha512sum }}"
- get_attributes: false
- get_checksum: false
- get_mime: false
- register: sha512sums_stat
-
- - name: Fetch the sha512sums file
- become: true
- become_method: ansible.builtin.sudo
- ansible.builtin.get_url:
- url: "{{ guestfs_custom_raw_image_sha512sums_url }}"
- dest: "{{ custom_image_dir }}"
- mode: "u=rw,g=r,o=r"
- when:
- - not sha512sums_stat.stat.exists
-
- - name: Compute checksum of something
- ansible.builtin.command:
- cmd: "sha512sum --ignore-missing -c {{ sha512sums_file }}"
- chdir: "{{ custom_image_dir }}"
- changed_when: false
- name: Get the UID of the kdevops user on the control host
ansible.builtin.command:
--
2.50.1
next prev parent reply other threads:[~2025-08-27 3:57 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-27 3:57 [RFT 0/4] guestfs: few custom image fixes Luis Chamberlain
2025-08-27 3:57 ` [RFT 1/4] guestfs: fix custom image partition not expanded after disk resize Luis Chamberlain
2025-08-27 3:57 ` [RFT 2/4] guestfs: fix custom image bringup failure for Debian 13 Luis Chamberlain
2025-08-27 3:57 ` [RFT 3/4] guestfs: fix virt-resize failure for custom images Luis Chamberlain
2025-08-27 3:57 ` Luis Chamberlain [this message]
2025-08-29 2:01 ` [RFT 0/4] guestfs: few custom image fixes Luis Chamberlain
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250827035747.3314144-5-mcgrof@kernel.org \
--to=mcgrof@kernel.org \
--cc=cel@kernel.org \
--cc=da.gomez@kruces.com \
--cc=kdevops@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox