Changed retry logic on buildah build
- Enable logging of retries as warnings
- Increase number of retries to 5 and switched delay from 1s
to exponential, capping at 60s
Example:
WARNING...:Finished call to '__main__.foo' after 9.201(s), this was the 6th time calling it.
Change-Id: If13571b9e21251ced9a43fc1cc7f7d69fad06f0a
Tested-By: https://review.rdoproject.org/r/#/c/29917/
(cherry picked from commit a584a5bd4c
)
This commit is contained in:
parent
0d12d83526
commit
9a4744e110
|
@ -29,12 +29,13 @@ from tripleo_common.image.builder import base
|
||||||
from tripleo_common.utils import process
|
from tripleo_common.utils import process
|
||||||
|
|
||||||
CONF = cfg.CONF
|
CONF = cfg.CONF
|
||||||
|
LOG = logging.getLogger(__name__ + ".BuildahBuilder")
|
||||||
|
|
||||||
|
|
||||||
class BuildahBuilder(base.BaseBuilder):
|
class BuildahBuilder(base.BaseBuilder):
|
||||||
"""Builder to build container images with Buildah."""
|
"""Builder to build container images with Buildah."""
|
||||||
|
|
||||||
log = logging.getLogger(__name__ + ".BuildahBuilder")
|
log = LOG
|
||||||
|
|
||||||
def __init__(self, work_dir, deps, base='fedora', img_type='binary',
|
def __init__(self, work_dir, deps, base='fedora', img_type='binary',
|
||||||
tag='latest', namespace='master',
|
tag='latest', namespace='master',
|
||||||
|
@ -144,10 +145,13 @@ class BuildahBuilder(base.BaseBuilder):
|
||||||
self.log.exception(e)
|
self.log.exception(e)
|
||||||
raise
|
raise
|
||||||
|
|
||||||
@tenacity.retry( # Retry up to 3 times with 1 second delay
|
@tenacity.retry(
|
||||||
|
# Retry up to 5 times: 0, 1, 5, 21, 85
|
||||||
|
# http://exponentialbackoffcalculator.com/
|
||||||
reraise=True,
|
reraise=True,
|
||||||
wait=tenacity.wait_fixed(1),
|
wait=tenacity.wait_random_exponential(multiplier=4, max=60),
|
||||||
stop=tenacity.stop_after_attempt(3)
|
stop=tenacity.stop_after_attempt(5),
|
||||||
|
before_sleep=tenacity.after_log(LOG, logging.WARNING)
|
||||||
)
|
)
|
||||||
def build(self, container_name, container_build_path):
|
def build(self, container_name, container_build_path):
|
||||||
"""Build an image from a given directory.
|
"""Build an image from a given directory.
|
||||||
|
@ -190,7 +194,8 @@ class BuildahBuilder(base.BaseBuilder):
|
||||||
@tenacity.retry( # Retry up to 10 times with jittered exponential backoff
|
@tenacity.retry( # Retry up to 10 times with jittered exponential backoff
|
||||||
reraise=True,
|
reraise=True,
|
||||||
wait=tenacity.wait_random_exponential(multiplier=1, max=15),
|
wait=tenacity.wait_random_exponential(multiplier=1, max=15),
|
||||||
stop=tenacity.stop_after_attempt(10)
|
stop=tenacity.stop_after_attempt(10),
|
||||||
|
before_sleep=tenacity.after_log(LOG, logging.WARNING)
|
||||||
)
|
)
|
||||||
def push(self, destination):
|
def push(self, destination):
|
||||||
"""Push an image to a container registry.
|
"""Push an image to a container registry.
|
||||||
|
|
Loading…
Reference in New Issue