Skip to content

Commit 17a0ef0

Browse files
committed
fix(registry): catch docker timeouts and show a nicer error
Based on data found in https://gist.github.com/slack/09d11a6986e4e9a8d939ad22204a1be3
1 parent 01df2e1 commit 17a0ef0

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

rootfs/registry/dockerclient.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import docker.constants
1414
from docker.auth import auth
1515
from docker.errors import APIError
16+
import requests
1617

1718
logger = logging.getLogger(__name__)
1819

@@ -173,10 +174,14 @@ def check_blacklist(repo):
173174

174175
def log_output(stream, operation, repo, tag):
175176
"""Log a stream at DEBUG level, and raise RegistryException if it contains an error"""
176-
for chunk in stream:
177-
# error handling requires looking at the response body
178-
if 'error' in chunk:
179-
stream_error(chunk, operation, repo, tag)
177+
try:
178+
for chunk in stream:
179+
# error handling requires looking at the response body
180+
if 'error' in chunk:
181+
stream_error(chunk, operation, repo, tag)
182+
except requests.packages.urllib3.exceptions.ReadTimeoutError as e:
183+
message = 'Operation {} timed out for image {}:{}'.format(operation, repo, tag)
184+
raise RegistryException(message) from e
180185

181186

182187
def stream_error(chunk, operation, repo, tag):

0 commit comments

Comments
 (0)