Add download retries option (#9911)

Signed-off-by: tu1h <lihai.tu@daocloud.io>
pull/9915/head
tu1h 2023-03-22 00:38:12 +08:00 committed by GitHub
parent f73b941d8a
commit 8cf5fefe84
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 5 deletions

View File

@ -50,6 +50,9 @@ download_validate_certs: true
# Use the first kube_control_plane if download_localhost is not set # Use the first kube_control_plane if download_localhost is not set
download_delegate: "{% if download_localhost %}localhost{% else %}{{ groups['kube_control_plane'][0] }}{% endif %}" download_delegate: "{% if download_localhost %}localhost{% else %}{{ groups['kube_control_plane'][0] }}{% endif %}"
# Allow control the times of download retries for files and containers
download_retries: 4
# The docker_image_info_command might seems weird but we are using raw/endraw and `{{ `{{` }}` to manage the double jinja2 processing # The docker_image_info_command might seems weird but we are using raw/endraw and `{{ `{{` }}` to manage the double jinja2 processing
docker_image_pull_command: "{{ docker_bin_dir }}/docker pull" docker_image_pull_command: "{{ docker_bin_dir }}/docker pull"
docker_image_info_command: "{{ docker_bin_dir }}/docker images -q | xargs -i {{ '{{' }} docker_bin_dir }}/docker inspect -f {% raw %}'{{ '{{' }} if .RepoTags }}{{ '{{' }} join .RepoTags \",\" }}{{ '{{' }} end }}{{ '{{' }} if .RepoDigests }},{{ '{{' }} join .RepoDigests \",\" }}{{ '{{' }} end }}' {% endraw %} {} | tr '\n' ','" docker_image_info_command: "{{ docker_bin_dir }}/docker images -q | xargs -i {{ '{{' }} docker_bin_dir }}/docker inspect -f {% raw %}'{{ '{{' }} if .RepoTags }}{{ '{{' }} join .RepoTags \",\" }}{{ '{{' }} end }}{{ '{{' }} if .RepoDigests }},{{ '{{' }} join .RepoDigests \",\" }}{{ '{{' }} end }}' {% endraw %} {} | tr '\n' ','"

View File

@ -60,7 +60,7 @@
register: pull_task_result register: pull_task_result
until: pull_task_result is succeeded until: pull_task_result is succeeded
delay: "{{ retry_stagger | random + 3 }}" delay: "{{ retry_stagger | random + 3 }}"
retries: 4 retries: "{{ download_retries }}"
become: "{{ user_can_become_root | default(false) or not download_localhost }}" become: "{{ user_can_become_root | default(false) or not download_localhost }}"
environment: "{{ proxy_env if container_manager == 'containerd' else omit }}" environment: "{{ proxy_env if container_manager == 'containerd' else omit }}"
when: when:
@ -101,7 +101,7 @@
register: upload_image register: upload_image
failed_when: not upload_image failed_when: not upload_image
until: upload_image is succeeded until: upload_image is succeeded
retries: 4 retries: "{{ download_retries }}"
delay: "{{ retry_stagger | random + 3 }}" delay: "{{ retry_stagger | random + 3 }}"
when: when:
- pull_required - pull_required

View File

@ -64,7 +64,7 @@
run_once: "{{ download_force_cache }}" run_once: "{{ download_force_cache }}"
register: uri_result register: uri_result
until: uri_result is success until: uri_result is success
retries: 4 retries: "{{ download_retries }}"
delay: "{{ retry_stagger | default(5) }}" delay: "{{ retry_stagger | default(5) }}"
environment: "{{ proxy_env }}" environment: "{{ proxy_env }}"
no_log: "{{ not (unsafe_show_logs|bool) }}" no_log: "{{ not (unsafe_show_logs|bool) }}"
@ -97,7 +97,7 @@
register: get_url_result register: get_url_result
become: "{{ not download_localhost }}" become: "{{ not download_localhost }}"
until: "'OK' in get_url_result.msg or 'file already exists' in get_url_result.msg" until: "'OK' in get_url_result.msg or 'file already exists' in get_url_result.msg"
retries: 4 retries: "{{ download_retries }}"
delay: "{{ retry_stagger | default(5) }}" delay: "{{ retry_stagger | default(5) }}"
environment: "{{ proxy_env }}" environment: "{{ proxy_env }}"
no_log: "{{ not (unsafe_show_logs|bool) }}" no_log: "{{ not (unsafe_show_logs|bool) }}"
@ -122,7 +122,7 @@
register: get_task register: get_task
until: get_task is succeeded until: get_task is succeeded
delay: "{{ retry_stagger | random + 3 }}" delay: "{{ retry_stagger | random + 3 }}"
retries: 4 retries: "{{ download_retries }}"
when: when:
- download_force_cache - download_force_cache