Skip to content

Commit

Permalink
feat(internet): add retries for internet dependent states
Browse files Browse the repository at this point in the history
  • Loading branch information
noelmcloughlin committed Jul 1, 2019
1 parent 40f0541 commit 7660dbd
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 5 deletions.
7 changes: 2 additions & 5 deletions packages/archives.sls
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,7 @@ packages-archive-wanted-download-{{ package }}:
cmd.run:
- name: curl -s -L -o {{ packages.tmpdir }}/{{ archivename }} {{ archive.dl.source }}
- unless: test -f {{ packages.tmpdir }}/{{ archivename }}
- retry:
attempts: 2
until: True
interval: 60
splay: 10
- retry: {{ packages.retry_options|json }}
{%- if 'hashsum' in archive.dl and archive.dl.hashsum %}
{# see https://github.com/saltstack/salt/pull/41914 #}
Expand Down Expand Up @@ -96,6 +92,7 @@ packages-archive-wanted-download-{{ package }}:
{%- else %}
- skip_verify: True
{%- endif %}
- retry: {{ packages.retry_options|json }}
{% endif %}
{%- endfor %}
6 changes: 6 additions & 0 deletions packages/defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,9 @@ packages:
unwanted: []
required:
archives: {} #note: dict
retry_options:
# https://docs.saltstack.com/en/latest/ref/states/requisites.html#retrying-states
attempts: 3
until: True
interval: 60
splay: 10
2 changes: 2 additions & 0 deletions packages/gems.sls
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ include:
gem_req_pkgs:
pkg.installed:
- pkgs: {{ req_pkgs | json }}
- retry: {{ packages.retry_options|json }}
### GEMS to install
# (requires the ruby/rubygem deb/rpm installed, either by the system or listed in
Expand All @@ -32,6 +33,7 @@ gem_req_pkgs:
- sls: {{ dep }}
{% endfor %}
{% endif %}
- retry: {{ packages.retry_options|json }}
{% endfor %}
{% for ugm in unwanted_gems %}
Expand Down
1 change: 1 addition & 0 deletions packages/npms.sls
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ wanted_npms:
- sls: {{ dep }}
{% endfor %}
{% endif %}
- retry: {{ packages.retry_options|json }}
{% for upn in unwanted_npms %}
{{ upn }}:
Expand Down
1 change: 1 addition & 0 deletions packages/pips.sls
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ packages pips install {{ pn }}:
{% if pip_config %}
- file: pip_config
{% endif %}
- retry: {{ packages.retry_options|json }}
{% endfor %}
{% for upn in unwanted_pips %}
Expand Down
3 changes: 3 additions & 0 deletions packages/pkgs.sls
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ pkg_req_pkgs:
- sls: {{ dep }}
{% endfor %}
{% endif %}
- retry: {{ packages.retry_options|json }}
{% if held_packages != {} %}
held_pkgs:
Expand All @@ -47,6 +48,7 @@ held_pkgs:
{% for dep in req_states %}
- sls: {{ dep }}
{% endfor %}
- retry: {{ packages.retry_options|json }}
{% endif %}
wanted_pkgs:
Expand All @@ -62,6 +64,7 @@ wanted_pkgs:
- sls: {{ dep }}
{% endfor %}
{% endif %}
- retry: {{ packages.retry_options|json }}
unwanted_pkgs:
pkg.purged:
Expand Down
3 changes: 3 additions & 0 deletions packages/snaps.sls
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ extend:
- sls: {{ dep }}
{% endfor %}
{% endif %}
- retry: {{ packages.retry_options|json }}
{% if packages.snaps.symlink %}
{# classic confinement requires snaps under /snap or symlink from #}
Expand Down Expand Up @@ -72,6 +73,7 @@ packages-snapd-{{ snap }}-wanted:
- require:
- pkg: pkg_req_pkgs
- pkg: unwanted_pkgs
- retry: {{ packages.retry_options|json }}
{% endfor %}
### SNAPS to install in classic mode
Expand All @@ -84,6 +86,7 @@ packages-snapd-{{ snap }}-classic:
- require:
- pkg: pkg_req_pkgs
- pkg: unwanted_pkgs
- retry: {{ packages.retry_options|json }}
{% endfor %}
### SNAPS to uninstall
Expand Down
6 changes: 6 additions & 0 deletions pillar.example
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,9 @@ packages:
remote_pkgs:
zoom: 'https://zoom.us/client/latest/zoom_amd64.deb'

retry_options:
# https://docs.saltstack.com/en/latest/ref/states/requisites.html#retrying-states
attempts: 5
until: True
interval: 30
splay: 20

0 comments on commit 7660dbd

Please sign in to comment.