Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PR #5984/9b5d907d backport][3.49] Add ClientConnectionError as retriable exception on content-app streaming #6012

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES/5967.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
On the content-app, added ClientConnectionError (aiohttp) as an exception that can trigger
a retry when streaming content from a Remote.
12 changes: 9 additions & 3 deletions pulpcore/content/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import re
from gettext import gettext as _

from aiohttp.client_exceptions import ClientResponseError
from aiohttp.client_exceptions import ClientResponseError, ClientConnectionError
from aiohttp.web import FileResponse, StreamResponse, HTTPOk
from aiohttp.web_exceptions import (
HTTPError,
Expand Down Expand Up @@ -808,6 +808,13 @@ async def _stream_content_artifact(self, request, response, content_artifact):
:class:`~pulpcore.plugin.models.ContentArtifact` returned the binary data needed for
the client.
"""
# We should only retry with exceptions that happen before we receive any data
# and start streaming, as we can't rollback data if something happens after that.
RETRYABLE_EXCEPTIONS = (
ClientResponseError,
UnsupportedDigestValidationError,
ClientConnectionError,
)

remote_artifacts = content_artifact.remoteartifact_set.select_related(
"remote"
Expand All @@ -816,8 +823,7 @@ async def _stream_content_artifact(self, request, response, content_artifact):
try:
response = await self._stream_remote_artifact(request, response, remote_artifact)
return response

except (ClientResponseError, UnsupportedDigestValidationError) as e:
except RETRYABLE_EXCEPTIONS as e:
log.warning(
"Could not download remote artifact at '{}': {}".format(
remote_artifact.url, str(e)
Expand Down