Skip to content

Commit

Permalink
Backport workaround for adding RA cooldown
Browse files Browse the repository at this point in the history
Original backport with migration already removed:
2f3b57b

This adds unique migration field and update the code to use it.
This will avoid conflicts with future fields.

Must be cleaned up on a future release with an idempotent remove migration.
  • Loading branch information
pedro-psb committed Jan 10, 2025
1 parent 2f3b57b commit 5fa9019
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.2.17 on 2025-01-10 20:56

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('core', '0117_task_unblocked_at'),
]

operations = [
migrations.AddField(
model_name='remoteartifact',
name='failed_at_backport49',
field=models.DateTimeField(null=True),
),
]
5 changes: 5 additions & 0 deletions pulpcore/app/models/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,10 @@ class RemoteArtifact(BaseModel, QueryMixin):
sha256 (models.CharField): The expected SHA-256 checksum of the file.
sha384 (models.CharField): The expected SHA-384 checksum of the file.
sha512 (models.CharField): The expected SHA-512 checksum of the file.
failed_at_backport49 (models.DateTimeField):
The datetime of last download attempt failure. Only for old branches to
avoid migration backport issues.
Relations:
Expand All @@ -725,6 +729,7 @@ class RemoteArtifact(BaseModel, QueryMixin):
content_artifact = models.ForeignKey(ContentArtifact, on_delete=models.CASCADE)
remote = models.ForeignKey("Remote", on_delete=models.CASCADE)
pulp_domain = models.ForeignKey("Domain", default=get_domain_pk, on_delete=models.PROTECT)
failed_at_backport49 = models.DateTimeField(null=True)

objects = BulkCreateManager.from_queryset(RemoteArtifactQuerySet)()

Expand Down
4 changes: 2 additions & 2 deletions pulpcore/content/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,7 @@ async def _stream_content_artifact(self, request, response, content_artifact):
remote_artifacts = (
content_artifact.remoteartifact_set.select_related("remote")
.order_by_acs()
.exclude(failed_at__gte=timezone.now() - timedelta(seconds=protection_time))
.exclude(failed_at_backport49__gte=timezone.now() - timedelta(seconds=protection_time))
)
async for remote_artifact in remote_artifacts:
try:
Expand Down Expand Up @@ -1126,7 +1126,7 @@ async def finalize():
try:
download_result = await downloader.run()
except DigestValidationError:
remote_artifact.failed_at = timezone.now()
remote_artifact.failed_at_backport49 = timezone.now()
await remote_artifact.asave()
await downloader.session.close()
close_tcp_connection(request.transport._sock)
Expand Down

0 comments on commit 5fa9019

Please sign in to comment.