Skip to content

Commit

Permalink
Fixed artifact_stages edge case for multi-artifact/multi-remote batches.
Browse files Browse the repository at this point in the history
Only encountered when 2to3-migrating specific content in specific orders.

backports #8377
https://pulp.plan.io/issues/8377
re #8485
https://pulp.plan.io/issues/8485

(cherry picked from commit b23c929)
  • Loading branch information
ggainey authored and goosemania committed Apr 9, 2021
1 parent 459aedd commit 94a0c35
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGES/8377.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed artifact-stage to handle an edge-case when multiple multi-artifact content, from different remotes, is in a single batch.
21 changes: 12 additions & 9 deletions pulpcore/plugin/stages/artifact_stages.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,22 +283,25 @@ def _needed_remote_artifacts(self, batch):
)
needed_ras = []
for d_content in batch:
for content_artifact in d_content.content._remote_artifact_saver_cas:
for d_artifact in d_content.d_artifacts:
for d_artifact in d_content.d_artifacts:
if not d_artifact.remote:
continue

for content_artifact in d_content.content._remote_artifact_saver_cas:
if d_artifact.relative_path == content_artifact.relative_path:
break
else:
msg = _('No declared artifact with relative path "{rp}" for content "{c}"')
raise ValueError(
msg.format(rp=content_artifact.relative_path, c=d_content.content)
)
if d_artifact.remote:
for remote_artifact in content_artifact._remote_artifact_saver_ras:
if remote_artifact.remote_id == d_artifact.remote.pk:
break
else:
remote_artifact = self._create_remote_artifact(d_artifact, content_artifact)
needed_ras.append(remote_artifact)

for remote_artifact in content_artifact._remote_artifact_saver_ras:
if remote_artifact.remote_id == d_artifact.remote.pk:
break
else:
remote_artifact = self._create_remote_artifact(d_artifact, content_artifact)
needed_ras.append(remote_artifact)
return needed_ras

@staticmethod
Expand Down

0 comments on commit 94a0c35

Please sign in to comment.