base_image: move size adjustment until after we verify checksums
PATCH 1/1 base_image: move size adjustment until after we verify checksums
Move the sha512 checksum check to run *after* we resize the image. Otherwise we fail.
--- .../roles/base_image/tasks/custom-image.yml | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-)
playbooks/roles/base_image/tasks/custom-image.yml +9 -10
@@ -46,16 +46,6 @@ - not custom_image_stat.stat.exists - guestfs_has_custom_raw_image_url|bool -- name: Resize custom image to match configured size - become: true - become_method: ansible.builtin.sudo - ansible.builtin.command: - cmd: "qemu-img resize {{ custom_image }} {{ libvirt_image_size }}" - changed_when: true - when: - - custom_image_download is changed or custom_image_stat.stat.exists - - guestfs_has_custom_raw_image_url|bool - - name: Check if the custom image sentinel file already exists ansible.builtin.stat: path: "{{ custom_image_ok }}"
@@ -124,6 +114,15 @@ - not sentinel_stat.stat.exists - id_output.rc != 0 + - name: Resize custom image to match configured size + become: true + become_method: ansible.builtin.sudo + ansible.builtin.command: + cmd: "qemu-img resize -f raw {{ custom_image }} {{ libvirt_image_size }}" + changed_when: true + when: + - not sentinel_stat.stat.exists + - name: Create a temporary file for virt-customize commands ansible.builtin.tempfile: state: file
Signature · 1 line
2.45.2
Quoted 1 line · Luis Chamberlain
Move the sha512 checksum check to run *after* we resize the image.
I think you mean: move the sha512 checksum to run before we resize the image. Or after we download the image.
Quoted 3 lines
Otherwise we fail.
Signed-off-by Luis Chamberlain <[email protected]>
I'm not sure why I could not replicate this but I agree (if the above was the initial intention) with the change. We should check the checksum immediately after download, otherwise the resize step changes the checksum.
The patch however, is not 100% correct. So, can you ensure:
* To check checksum right after download
* To skip the checksum check if the file already exists
* To resize only after downloading (custom_image_download)
Quoted 28 lines
--- .../roles/base_image/tasks/custom-image.yml | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-)playbooks/roles/base_image/tasks/custom-image.yml +0
-10@@ -46,16 +46,6 @@ - not custom_image_stat.stat.exists - guestfs_has_custom_raw_image_url|bool -- name: Resize custom image to match configured size - become: true - become_method: ansible.builtin.sudo - ansible.builtin.command: - cmd: "qemu-img resize {{ custom_image }} {{ libvirt_image_size }}" - changed_when: true - when: - - custom_image_download is changed or custom_image_stat.stat.exists - - guestfs_has_custom_raw_image_url|bool - - name: Check if the custom image sentinel file already exists ansible.builtin.stat: path: "{{ custom_image_ok }}"@@ -124,6 +114,15 @@ - not sentinel_stat.stat.exists - id_output.rc != 0
playbooks/roles/base_image/tasks/custom-image.yml line 125
Quoted 10 lines
playbooks/roles/base_image/tasks/custom-image.yml +9
-0+ - name: Resize custom image to match configured size + become: true + become_method: ansible.builtin.sudo + ansible.builtin.command: + cmd: "qemu-img resize -f raw {{ custom_image }} {{ libvirt_image_size }}" + changed_when: true + when: + - not sentinel_stat.stat.exists +
I think the conditions here are not correct. We should resize only after downloading. Or can we safely resize (grow/shrink) the image after bringup?
Quoted 3 lines
playbooks/roles/base_image/tasks/custom-image.yml +0
-0- name: Create a temporary file for virt-customize commands ansible.builtin.tempfile: state: file