From 46e10d21f15fa7ec50c35e800125278e270f46b6 Mon Sep 17 00:00:00 2001 From: Dmitriy Rabotyagov Date: Thu, 22 Oct 2020 12:26:44 +0300 Subject: [PATCH] Determine latest base image available Closes-Bug: #1900884 Closes-Bug: #1900975 Change-Id: I362a15397fee891d967ce7150819b02312200d2e --- defaults/main.yml | 2 +- .../notes/lxc_image_url-a45e19531dc56ea4.yaml | 6 ++++++ tasks/lxc_cache_prestage.yml | 13 +++++++++++++ vars/ubuntu-18.04.yml | 4 +++- vars/ubuntu-20.04.yml | 4 +++- 5 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 releasenotes/notes/lxc_image_url-a45e19531dc56ea4.yaml diff --git a/defaults/main.yml b/defaults/main.yml index 77e9577a..bcab11e5 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -201,7 +201,7 @@ lxc_image_cache_server_mirrors: - https://images.linuxcontainers.org # URL for the image to build our containers -lxc_hosts_container_image_url: "{{ _lxc_hosts_container_image_url }}" +lxc_hosts_container_image_url: "{{ _lxc_hosts_container_image_url | default('') }}" # If enabled the image will be fetched from the legacy [images.linuxcontainers.org]. lxc_hosts_container_image_download_legacy: false diff --git a/releasenotes/notes/lxc_image_url-a45e19531dc56ea4.yaml b/releasenotes/notes/lxc_image_url-a45e19531dc56ea4.yaml new file mode 100644 index 00000000..fac2bdbe --- /dev/null +++ b/releasenotes/notes/lxc_image_url-a45e19531dc56ea4.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - | + Since Ubuntu has dropped older base images, which resulted in all previous + tags being broken, we've switched to downloading always latest base image + available. This should guarantee that we retrieve relevant images only. diff --git a/tasks/lxc_cache_prestage.yml b/tasks/lxc_cache_prestage.yml index 5d4fbff6..8230b24e 100644 --- a/tasks/lxc_cache_prestage.yml +++ b/tasks/lxc_cache_prestage.yml @@ -41,6 +41,19 @@ when: - lxc_hosts_container_image_download_legacy | bool +- name: Determine lxc_hosts_container_image_url when it is not explicitly set + set_fact: + lxc_hosts_container_image_url: "{{ _lxc_hosts_container_image_url_base ~ '/' ~ lookup('url', _lxc_hosts_container_image_url_base ~ '/' ~ _lxc_hosts_container_image_checksum_file) | regex_findall(_lxc_hosts_container_image_checksum_regexp) | max }}" + register: image_url + retries: 3 + delay: 1 + until: image_url is success + when: + - not lxc_hosts_container_image_url | bool + - _lxc_hosts_container_image_url_base is defined + - _lxc_hosts_container_image_checksum_file is defined + - _lxc_hosts_container_image_checksum_regexp is defined + - name: Set LXC cache basename set_fact: cache_basename: "{{ lxc_hosts_container_image_url | basename }}" diff --git a/vars/ubuntu-18.04.yml b/vars/ubuntu-18.04.yml index 4e39d592..fba7c65a 100644 --- a/vars/ubuntu-18.04.yml +++ b/vars/ubuntu-18.04.yml @@ -13,7 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -_lxc_hosts_container_image_url: "http://cdimage.ubuntu.com/ubuntu-base/releases/18.04/release/ubuntu-base-18.04.3-base-{{ lxc_cache_map.arch }}.tar.gz" +_lxc_hosts_container_image_url_base: "http://cdimage.ubuntu.com/ubuntu-base/releases/18.04/release" +_lxc_hosts_container_image_checksum_file: SHA256SUMS +_lxc_hosts_container_image_checksum_regexp: "ubuntu-base-18.04.[0-9]-base-{{ lxc_cache_map.arch }}.tar.gz" _lxc_cache_map: distro: ubuntu diff --git a/vars/ubuntu-20.04.yml b/vars/ubuntu-20.04.yml index f9b469a5..f1b8d832 100644 --- a/vars/ubuntu-20.04.yml +++ b/vars/ubuntu-20.04.yml @@ -13,7 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -_lxc_hosts_container_image_url: "http://cdimage.ubuntu.com/ubuntu-base/releases/20.04/release/ubuntu-base-20.04-base-{{ lxc_cache_map.arch }}.tar.gz" +_lxc_hosts_container_image_url_base: "http://cdimage.ubuntu.com/ubuntu-base/releases/20.04/release" +_lxc_hosts_container_image_checksum_file: SHA256SUMS +_lxc_hosts_container_image_checksum_regexp: "ubuntu-base-20.04.[0-9]-base-{{ lxc_cache_map.arch }}.tar.gz" _lxc_cache_map: distro: ubuntu