Skip to content

Commit 139b482

Browse files
author
Andrei Neagu
committed
update log entry
1 parent 24228c8 commit 139b482

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

packages/service-library/src/servicelib/docker_utils.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,14 @@
1212
from models_library.docker import DockerGenericTag
1313
from models_library.generated_models.docker_rest_api import ProgressDetail
1414
from models_library.utils.change_case import snake_to_camel
15-
from pydantic import BaseModel, ByteSize, ConfigDict, TypeAdapter, ValidationError
15+
from pydantic import (
16+
BaseModel,
17+
ByteSize,
18+
ConfigDict,
19+
NonNegativeInt,
20+
TypeAdapter,
21+
ValidationError,
22+
)
1623
from settings_library.docker_registry import RegistrySettings
1724
from tenacity import (
1825
AsyncRetrying,
@@ -216,6 +223,8 @@ async def pull_image(
216223
progress_bar: ProgressBarData,
217224
log_cb: LogCB,
218225
image_information: DockerImageManifestsV2 | None,
226+
*,
227+
retry_upon_error_count: NonNegativeInt = 10,
219228
) -> None:
220229
"""pull a docker image to the host machine.
221230
@@ -226,6 +235,7 @@ async def pull_image(
226235
progress_bar -- the current progress bar
227236
log_cb -- a callback function to send logs to
228237
image_information -- the image layer information. If this is None, then no fine progress will be retrieved.
238+
retry_upon_error_count -- number of tries if there is a TimeoutError. Usually cased by networking issues.
229239
"""
230240
registry_auth = None
231241
if registry_settings.REGISTRY_URL and registry_settings.REGISTRY_URL in image:
@@ -254,15 +264,16 @@ async def pull_image(
254264

255265
async for attempt in AsyncRetrying(
256266
wait=wait_random_exponential(),
257-
stop=stop_after_attempt(3),
267+
stop=stop_after_attempt(retry_upon_error_count),
258268
reraise=True,
259269
retry=retry_if_exception_type(asyncio.TimeoutError),
260270
):
261-
# each time there is an error progress start from zero again
271+
# each time there is an error progress starts from zero
262272
progress_bar.reset_progress()
263273
_logger.info(
264-
"Attemping for the count='%s' time to pull the image",
274+
"attempt='%s' to pull image='%s'",
265275
attempt.retry_state.attempt_number,
276+
image,
266277
)
267278

268279
with attempt:

0 commit comments

Comments
 (0)