Retry downloading traefik if it fails

Fixes #314
This commit is contained in:
yuvipanda
2019-05-19 22:29:18 -07:00
parent c0171dfdbc
commit 536e435c06
2 changed files with 9 additions and 2 deletions

View File

@@ -1,10 +1,11 @@
"""Traefik installation and setup"""
import hashlib
import os
from urllib.request import urlretrieve
from urllib.request import urlretrieve, ContentTooShortError
from jinja2 import Template
from passlib.apache import HtpasswdFile
import backoff
from tljh.configurer import load_config
@@ -26,7 +27,12 @@ def checksum_file(path):
hasher.update(chunk)
return hasher.hexdigest()
@backoff.on_exception(
backoff.expo,
# Retry when connection is reset or we think we didn't download entire file
(ConnectionResetError, ContentTooShortError),
max_tries=2
)
def ensure_traefik_binary(prefix):
"""Download and install the traefik binary"""
traefik_bin = os.path.join(prefix, "bin", "traefik")