From 8a77316d2d73dd31d6f47b964bf148a602da6a21 Mon Sep 17 00:00:00 2001 From: David Davis Date: Wed, 24 Mar 2021 12:22:42 -0400 Subject: [PATCH] Have the content app handle UnsupportedDigestValidationError In https://pulp.plan.io/issues/8435 we added a check to downloader to prevent the download of files without allowed checksums. This code updates the downloader to handle the exception that gets raised. fixes #7989 --- CHANGES/7989.feature | 1 + pulpcore/content/handler.py | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 CHANGES/7989.feature diff --git a/CHANGES/7989.feature b/CHANGES/7989.feature new file mode 100644 index 0000000000..6d96b4022c --- /dev/null +++ b/CHANGES/7989.feature @@ -0,0 +1 @@ +Added support in content app for properly handling unknown or forbidden digest errors. diff --git a/pulpcore/content/handler.py b/pulpcore/content/handler.py index 150f8e15ae..1d11b9b6c7 100644 --- a/pulpcore/content/handler.py +++ b/pulpcore/content/handler.py @@ -30,6 +30,7 @@ Remote, RemoteArtifact, ) +from pulpcore.exceptions import UnsupportedDigestValidationError # noqa: E402 from jinja2 import Template # noqa: E402: module level not at top of file @@ -501,7 +502,12 @@ async def _stream_content_artifact(self, request, response, content_artifact): response = await self._stream_remote_artifact(request, response, remote_artifact) return response - except ClientResponseError: + except (ClientResponseError, UnsupportedDigestValidationError) as e: + log.warn( + _("Could not download remote artifact at '{}': {}").format( + remote_artifact.url, str(e) + ) + ) continue raise HTTPNotFound()