From 7e8e60f9c1d9e247033d3aab7366d0913f382566 Mon Sep 17 00:00:00 2001 From: Dmitry Tantsur Date: Wed, 9 Sep 2020 15:57:15 +0200 Subject: [PATCH] Re-download checkums on upgrades and updates Currently it may happen so that the stable checksum file is new enough for get_url to skip re-downloading it, resulting in an upgrade failure. Also refactor download_ipa_image based on the fact that checksums are published for all images since Pike. Change-Id: I6fc0e6bee8e6b7999c198ca7ab631dd3c40eb216 --- .../tasks/download_ipa_image.yml | 114 ++++++------------ ...download-ipa-upgrade-91e0fc4beea7419e.yaml | 4 + 2 files changed, 40 insertions(+), 78 deletions(-) create mode 100644 releasenotes/notes/download-ipa-upgrade-91e0fc4beea7419e.yaml diff --git a/playbooks/roles/bifrost-ironic-install/tasks/download_ipa_image.yml b/playbooks/roles/bifrost-ironic-install/tasks/download_ipa_image.yml index 7ffa70e1e..38b35178c 100644 --- a/playbooks/roles/bifrost-ironic-install/tasks/download_ipa_image.yml +++ b/playbooks/roles/bifrost-ironic-install/tasks/download_ipa_image.yml @@ -19,45 +19,24 @@ stat: path={{ ipa_kernel }} register: test_ipa_kernel_present -- block: - - name: "Download IPA kernel checksum file" - get_url: - url: "{{ ipa_kernel_upstream_checksum_url }}" - dest: "{{ ipa_kernel }}.{{ ipa_kernel_upstream_checksum_algo }}" - timeout: 300 - owner: ironic - group: ironic - mode: 0644 - register: ipa_kernel_checksum_result - ignore_errors: yes - - debug: - msg: "WARNING!!! {{ ipa_kernel_upstream_checksum_algo }} file not found at {{ ipa_kernel_upstream_checksum_url }}" - when: - - ipa_kernel_checksum_result is defined - - ipa_kernel_checksum_result.status_code is defined - - ipa_kernel_checksum_result.status_code == 404 - - fail: - msg: "FATAL {{ ipa_kernel_upstream_checksum_algo }} file not found at {{ ipa_kernel_upstream_checksum_url }} GOT {{ ipa_kernel_checksum_result }}" - when: > - ipa_kernel_checksum_result is not defined - or ipa_kernel_checksum_result.changed is not defined - or (ipa_kernel_checksum_result.changed - and ipa_kernel_checksum_result.status_code is defined - and ipa_kernel_checksum_result.status_code != 404 - and ipa_kernel_checksum_result.status_code != 200) - - name: "Extract IPA kernel checksum" - shell: awk '/{{ ipa_kernel_upstream_url | basename }}/{print $1}' "{{ ipa_kernel }}.{{ ipa_kernel_upstream_checksum_algo }}" - register: parsed_ipa_kernel_checksum - when: not ipa_kernel_checksum_result is failed - - fail: - msg: "Failed to extract checksum for {{ ipa_kernel_upstream_url | basename }}" - when: - - not ipa_kernel_checksum_result is failed - - not parsed_ipa_kernel_checksum.stdout - - set_fact: - ipa_kernel_checksum: "{{ ipa_kernel_upstream_checksum_algo }}:{{ parsed_ipa_kernel_checksum.stdout }}" - when: not ipa_kernel_checksum_result is failed - when: ipa_kernel_upstream_checksum_url | length > 0 +- name: "Download IPA kernel checksum file" + get_url: + url: "{{ ipa_kernel_upstream_checksum_url }}" + dest: "{{ ipa_kernel }}.{{ ipa_kernel_upstream_checksum_algo }}" + timeout: 300 + force: yes + owner: ironic + group: ironic + mode: 0644 + +- name: "Extract IPA kernel checksum" + command: awk '/{{ ipa_kernel_upstream_url | basename }}/{print $1}' "{{ ipa_kernel }}.{{ ipa_kernel_upstream_checksum_algo }}" + register: parsed_ipa_kernel_checksum + failed_when: parsed_ipa_kernel_checksum is failed + or not parsed_ipa_kernel_checksum.stdout + +- set_fact: + ipa_kernel_checksum: "{{ ipa_kernel_upstream_checksum_algo }}:{{ parsed_ipa_kernel_checksum.stdout }}" - name: "Download IPA kernel" get_url: @@ -83,45 +62,24 @@ stat: path={{ ipa_ramdisk }} register: test_ipa_image_present -- block: - - name: "Download IPA image checksum" - get_url: - url: "{{ ipa_ramdisk_upstream_checksum_url }}" - dest: "{{ ipa_ramdisk }}.{{ ipa_ramdisk_upstream_checksum_algo }}" - timeout: 300 - owner: ironic - group: ironic - mode: 0644 - register: ipa_ramdisk_checksum_result - ignore_errors: yes - - debug: - msg: "WARNING!!! {{ ipa_ramdisk_upstream_checksum_algo }} file not found at {{ ipa_ramdisk_upstream_checksum_url }}" - when: - - ipa_ramdisk_checksum_result is defined - - ipa_ramdisk_checksum_result.status_code is defined - - ipa_ramdisk_checksum_result.status_code == 404 - - fail: - msg: "FATAL {{ ipa_ramdisk_upstream_checksum_algo }} file not found at {{ ipa_ramdisk_upstream_checksum_url }}" - when: > - ipa_ramdisk_checksum_result is not defined - or ipa_ramdisk_checksum_result.changed is not defined - or (ipa_ramdisk_checksum_result.changed - and ipa_ramdisk_checksum_result.status_code is defined - and ipa_ramdisk_checksum_result.status_code != 404 - and ipa_ramdisk_checksum_result.status_code != 200) - - name: "Extract IPA ramdisk checksum" - shell: awk '/{{ ipa_ramdisk_upstream_url | basename }}/{print $1}' "{{ ipa_ramdisk }}.{{ ipa_ramdisk_upstream_checksum_algo }}" - register: parsed_ipa_ramdisk_checksum - when: not ipa_ramdisk_checksum_result is failed - - fail: - msg: "Failed to extract checksum for {{ ipa_ramdisk_upstream_url | basename }}" - when: - - not ipa_ramdisk_checksum_result is failed - - not parsed_ipa_ramdisk_checksum.stdout - - set_fact: - ipa_ramdisk_checksum: "{{ ipa_ramdisk_upstream_checksum_algo }}:{{ parsed_ipa_ramdisk_checksum.stdout }}" - when: not ipa_ramdisk_checksum_result is failed - when: ipa_ramdisk_upstream_checksum_url | length > 0 +- name: "Download IPA image checksum" + get_url: + url: "{{ ipa_ramdisk_upstream_checksum_url }}" + dest: "{{ ipa_ramdisk }}.{{ ipa_ramdisk_upstream_checksum_algo }}" + timeout: 300 + force: yes + owner: ironic + group: ironic + mode: 0644 + +- name: "Extract IPA ramdisk checksum" + command: awk '/{{ ipa_ramdisk_upstream_url | basename }}/{print $1}' "{{ ipa_ramdisk }}.{{ ipa_ramdisk_upstream_checksum_algo }}" + register: parsed_ipa_ramdisk_checksum + failed_when: parsed_ipa_ramdisk_checksum is failed + or not parsed_ipa_ramdisk_checksum.stdout + +- set_fact: + ipa_ramdisk_checksum: "{{ ipa_ramdisk_upstream_checksum_algo }}:{{ parsed_ipa_ramdisk_checksum.stdout }}" - name: "Download IPA image" get_url: diff --git a/releasenotes/notes/download-ipa-upgrade-91e0fc4beea7419e.yaml b/releasenotes/notes/download-ipa-upgrade-91e0fc4beea7419e.yaml new file mode 100644 index 000000000..14e82f654 --- /dev/null +++ b/releasenotes/notes/download-ipa-upgrade-91e0fc4beea7419e.yaml @@ -0,0 +1,4 @@ +--- +fixes: + - | + Correctly updates IPA images checksums on a major upgrade.