Select the latest upgrade_data file during upgrade

When the upgrade_data_file isn't specified we search for files starting
with upgrade_data under /opt/platform-backup. With this change if
multiple files are found we select the most recent file.

Change-Id: I5e63cb1e76985522f764ea6e906f660c89838eb9
Partial-Bug: 1886041
Story: 2007403
Task: 40236
Signed-off-by: David Sullivan <david.sullivan@windriver.com>
This commit is contained in:
David Sullivan 2020-06-26 22:06:22 -04:00
parent 4d52c417e1
commit 766016fdf7

View File

@ -61,13 +61,14 @@
- name: Check presence of upgrade_data
fail:
msg: >
"Could not find upgrade_data file in {{ upgrade_data_dir }}.
Found {{ upgrade_data_find_output.matched }} matches."
when: upgrade_data_find_output.matched != 1
"Could not find upgrade_data file in {{ upgrade_data_dir }}."
when: upgrade_data_find_output.matched == 0
- name: Set upgrade_data value
set_fact:
restore_data_file: "{{ upgrade_data_find_output.files[0].path }}"
restore_data_file: "{{ latest_upgrade_data.path }}"
vars:
latest_upgrade_data: "{{ upgrade_data_find_output.files | sort(attribute='ctime', reverse=True) | first }}"
when: upgrade_data_file is not defined or upgrade_data_file is none