Skip to content

Commit

Permalink
move pull required check out of loop
Browse files Browse the repository at this point in the history
  • Loading branch information
Payback159 committed May 16, 2024
1 parent b06be00 commit af95c03
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions roles/download/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

# The image_info_command depends on the Container Runtime and will output something like the following:
# nginx:1.15,gcr.io/google-containers/kube-proxy:v1.14.1,gcr.io/google-containers/kube-proxy@sha256:44af2833c6cbd9a7fc2e9d2f5244a39dfd2e31ad91bf9d4b7d810678db738ee9,gcr.io/google-containers/kube-apiserver:v1.14.1,etc...
- name: Download | Generate a list of information about the images on a node # noqa command-instead-of-shell - image_info_command contains a pipe, therefore requiring shell
- name: Download | Generate a list of information about the images on a node # noqa command-instead-of-shell - image_info_command contains a pipe, therefore requiring shell
shell: "{{ image_info_command }}"
register: node_images
changed_when: false
Expand All @@ -30,20 +30,20 @@
msg: "{{ node_images.stdout }}"
when: not download_always_pull

#convert all items in downloads which have the key container set to true
#and check if the container exists in node_images.stdout.split(',')
# convert all items in downloads which have the key container set to true
# and check if the container exists in node_images.stdout.split(',')
# if yes, set the enabled key to false
#TODO: Some images are not cached on all nodes, which leads to repeated downloads... I still don't know why this is the case.
#TODO: Adapt to also support pull by sha256
# TODO: Some images are not cached on all nodes, which leads to repeated downloads... I still don't know why this is the case.
# TODO: Adapt to also support pull by sha256
- name: Download | Check if the container image is already present
set_fact:
downloads: "{{ downloads | combine({item.key: item.value | combine({'enabled': false})}) }}"
loop: "{{ downloads | dict2items }}"
when:
- not download_always_pull
- item.value.container is defined and item.value.container | bool == true
- item.value.container is defined and item.value.container
- item.value.repo + ':' + item.value.tag in node_images.stdout.split(',')
#- or item.value.repo + '@sha256:' + item.value.sha256 in node_images.stdout.split(',')
# - or item.value.repo + '@sha256:' + item.value.sha256 in node_images.stdout.split(',')
tags:
- download
- upload
Expand Down

0 comments on commit af95c03

Please sign in to comment.