Skip to content

Commit

Permalink
ref: retry on 500s in docker pulls
Browse files Browse the repository at this point in the history
  • Loading branch information
asottile-sentry committed Jan 25, 2023
1 parent 9a67a00 commit c62b7e3
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/sentry/runner/commands/devservices.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def get_or_create(


def retryable_pull(client: docker.DockerClient, image: str, max_attempts: int = 5) -> None:
from docker.errors import ImageNotFound
from docker.errors import APIError

current_attempt = 0

Expand All @@ -100,12 +100,13 @@ def retryable_pull(client: docker.DockerClient, image: str, max_attempts: int =
while True:
try:
client.images.pull(image)
except ImageNotFound as e:
except APIError:
if current_attempt + 1 >= max_attempts:
raise e
raise
current_attempt = current_attempt + 1
continue
break
else:
break


def ensure_interface(ports: dict[str, int | tuple[str, int]]) -> dict[str, tuple[str, int]]:
Expand Down

0 comments on commit c62b7e3

Please sign in to comment.