image_uplaoder: add retry to _layer_stream_registry
We have seen that uploading a layer can be problematic if the fetch is dropped by network issues (like it happens in OpenStack Infra). This patch adds a retry to the function that fetch the layer and retry if an HTTP exception is raised. Change-Id: Ia9716447a7d037aaf32c3b01ab511c08e6598e07 Closes-Bug: #1815576
This commit is contained in:
@@ -1066,6 +1066,14 @@ class PythonImageUploader(BaseImageUploader):
|
|||||||
return r.headers['Location']
|
return r.headers['Location']
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@tenacity.retry( # Retry up to 5 times with jittered exponential backoff
|
||||||
|
reraise=True,
|
||||||
|
retry=tenacity.retry_if_exception_type(
|
||||||
|
requests.exceptions.RequestException
|
||||||
|
),
|
||||||
|
wait=tenacity.wait_random_exponential(multiplier=1, max=10),
|
||||||
|
stop=tenacity.stop_after_attempt(5)
|
||||||
|
)
|
||||||
def _layer_stream_registry(cls, digest, source_url, calc_digest,
|
def _layer_stream_registry(cls, digest, source_url, calc_digest,
|
||||||
session):
|
session):
|
||||||
LOG.debug('Fetching layer: %s' % digest)
|
LOG.debug('Fetching layer: %s' % digest)
|
||||||
|
Reference in New Issue
Block a user