Skip to content

Commit bcc6013

Browse files
committed
Add ability to retry image pulling
Sometimes, the registries may intermittently fail to deliver the images. This is often seen in the CI, though it also happens with production deployments, even those with internal registries and/or registry mirrors - due to sheer load when trying to pull the images from many hosts. This patchs adds two new vars to control retry behaviour. The default has been set to make users happier by default. :-) Change-Id: I81ad7d8642654f8474f11084c6934aab40243d35 (cherry picked from commit cbb567c)
1 parent 431710f commit bcc6013

File tree

5 files changed

+50
-0
lines changed

5 files changed

+50
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
# Kolla image pulling settings: the amount of retries and the delay (in seconds)
3+
# between them. These are useful if your registry is not 100% reliable (usually
4+
# due to load). They modify the Ansible image pulling task params ``retries``
5+
# and ``delay``, respectively.
6+
service_images_pull_retries: 3
7+
service_images_pull_delay: 5

ansible/roles/service-images-pull/tasks/main.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
action: "pull_image"
88
common_options: "{{ docker_common_options }}"
99
image: "{{ service.image }}"
10+
retries: "{{ service_images_pull_retries }}"
11+
delay: "{{ service_images_pull_delay }}"
12+
register: result
13+
until: result is success
1014
with_dict: "{{ lookup('vars', (kolla_role_name | default(project_name)) + '_services') | select_services_enabled_and_mapped_to_host }}"
1115
loop_control:
1216
label: "{{ item.key }}"

ansible/roles/swift/defaults/main.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,9 @@ swift_ks_users:
9393
user: "{{ swift_keystone_user }}"
9494
password: "{{ swift_keystone_password }}"
9595
role: "admin"
96+
97+
98+
# FIXME(yoctozepto): These are copied from service-images-pull role.
99+
# Remove when the Swift role is finally migrated to new style.
100+
service_images_pull_retries: 3
101+
service_images_pull_delay: 5

ansible/roles/swift/tasks/pull.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
action: "pull_image"
66
common_options: "{{ docker_common_options }}"
77
image: "{{ swift_rsyncd_image_full }}"
8+
retries: "{{ service_images_pull_retries }}"
9+
delay: "{{ service_images_pull_delay }}"
10+
register: result
11+
until: result is success
812
when: inventory_hostname in groups['swift-account-server'] or
913
inventory_hostname in groups['swift-container-server'] or
1014
inventory_hostname in groups['swift-object-server']
@@ -15,6 +19,10 @@
1519
action: "pull_image"
1620
common_options: "{{ docker_common_options }}"
1721
image: "{{ swift_proxy_server_image_full }}"
22+
retries: "{{ service_images_pull_retries }}"
23+
delay: "{{ service_images_pull_delay }}"
24+
register: result
25+
until: result is success
1826
when: inventory_hostname in groups['swift-proxy-server']
1927

2028
- name: Pulling swift-account image
@@ -23,6 +31,10 @@
2331
action: "pull_image"
2432
common_options: "{{ docker_common_options }}"
2533
image: "{{ swift_account_image_full }}"
34+
retries: "{{ service_images_pull_retries }}"
35+
delay: "{{ service_images_pull_delay }}"
36+
register: result
37+
until: result is success
2638
when: inventory_hostname in groups['swift-account-server']
2739

2840
- name: Pulling swift-container image
@@ -31,6 +43,10 @@
3143
action: "pull_image"
3244
common_options: "{{ docker_common_options }}"
3345
image: "{{ swift_container_image_full }}"
46+
retries: "{{ service_images_pull_retries }}"
47+
delay: "{{ service_images_pull_delay }}"
48+
register: result
49+
until: result is success
3450
when: inventory_hostname in groups['swift-container-server']
3551

3652
- name: Pulling swift-object image
@@ -39,6 +55,10 @@
3955
action: "pull_image"
4056
common_options: "{{ docker_common_options }}"
4157
image: "{{ swift_object_image_full }}"
58+
retries: "{{ service_images_pull_retries }}"
59+
delay: "{{ service_images_pull_delay }}"
60+
register: result
61+
until: result is success
4262
when: inventory_hostname in groups['swift-object-server']
4363

4464
- name: Pulling swift-object-expirer image
@@ -47,4 +67,8 @@
4767
action: "pull_image"
4868
common_options: "{{ docker_common_options }}"
4969
image: "{{ swift_object_expirer_image_full }}"
70+
retries: "{{ service_images_pull_retries }}"
71+
delay: "{{ service_images_pull_delay }}"
72+
register: result
73+
until: result is success
5074
when: inventory_hostname in groups['swift-object-server']
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
features:
3+
- |
4+
Adds two new variables ``service_images_pull_retries`` and
5+
``service_images_pull_delay`` which control the behaviour of image
6+
pulling tasks. These are useful if your registry is not 100%
7+
reliable (usually due to load). The defaults have been set to
8+
3 retries and 5 seconds delay to ensure a better default experience
9+
(these are actually Ansible defaults when task retries are enabled).

0 commit comments

Comments
 (0)