Skip to content

Commit

Permalink
Taught repair task to be tolerant in the face of any artifact downloa…
Browse files Browse the repository at this point in the history
…d failure.

closes pulp#4111
  • Loading branch information
ipanova authored and dralley committed Jul 21, 2023
1 parent a6e81c7 commit 4310ea0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGES/4111.bugfix
@@ -0,0 +1 @@
Taught repair task to be tolerant in the face of any artifact download failure.
9 changes: 4 additions & 5 deletions pulpcore/app/management/commands/handle-artifact-checksums.py
Expand Up @@ -2,8 +2,6 @@

from gettext import gettext as _

from aiohttp.client_exceptions import ClientResponseError

from django.conf import settings
from django.core.management import BaseCommand, CommandError
from django.db.models import Q, Sum
Expand Down Expand Up @@ -126,7 +124,7 @@ def _download_artifact(self, artifact, checksum, file_path):
downloader = remote.get_downloader(ra)
try:
dl_result = downloader.fetch()
except ClientResponseError as e:
except Exception as e:
self.stdout.write(
_("Redownload failed from '{}': {}.").format(ra.url, str(e))
)
Expand All @@ -139,8 +137,9 @@ def _download_artifact(self, artifact, checksum, file_path):
setattr(artifact, checksum, dl_result.artifact_attributes[checksum])
restored = True
break
self.stdout.write(_("Deleting unreparable file {}".format(file_path)))
artifact.file.delete(save=False)
if not restored:
self.stdout.write(_("Deleting unrepairable file {}".format(file_path)))
artifact.file.delete(save=False)
else:
break
return restored
Expand Down
7 changes: 3 additions & 4 deletions pulpcore/app/tasks/repository.py
Expand Up @@ -4,7 +4,6 @@
import asyncio
import hashlib

from aiohttp.client_exceptions import ClientResponseError
from asgiref.sync import sync_to_async
from django.db import transaction
from rest_framework.serializers import ValidationError
Expand Down Expand Up @@ -68,7 +67,7 @@ async def _repair_ca(content_artifact, repaired=None):
"Artifact {} is unrepairable - no remote source".format(content_artifact.artifact)
)
log.warning(
"Deleting file for the unreparable artifact {}".format(content_artifact.artifact)
"Deleting file for the unrepairable artifact {}".format(content_artifact.artifact)
)
await sync_to_async(content_artifact.artifact.file.delete)(save=False)
return False
Expand All @@ -78,7 +77,7 @@ async def _repair_ca(content_artifact, repaired=None):
downloader = detail_remote.get_downloader(remote_artifact)
try:
dl_result = await downloader.run()
except ClientResponseError as e:
except Exception as e:
log.warn(_("Redownload failed from '{}': {}.").format(remote_artifact.url, str(e)))
else:
if dl_result.artifact_attributes["sha256"] == content_artifact.artifact.sha256:
Expand All @@ -91,7 +90,7 @@ async def _repair_ca(content_artifact, repaired=None):
if repaired is not None:
await repaired.aincrement()
return True
log.warning("Deleting file for the unreparable artifact {}".format(content_artifact.artifact))
log.warning("Deleting file for the unrepairable artifact {}".format(content_artifact.artifact))
await sync_to_async(content_artifact.artifact.file.delete)(save=False)
return False

Expand Down

0 comments on commit 4310ea0

Please sign in to comment.