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 #4211/3194be5b backport][3.22] Reset export to using a set() for Artifacts. #4214

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES/4210.bugfix
@@ -0,0 +1 @@
Fix a subtle export bug introduced from the optimizations in #4159.
5 changes: 2 additions & 3 deletions pulpcore/app/importexport.py
Expand Up @@ -94,14 +94,14 @@ def export_artifacts(export, artifacts):

Args:
export (django.db.models.PulpExport): export instance that's doing the export
artifacts (django.db.models.Artifacts): QuerySet of artifacts in all repos being exported
artifacts (django.db.models.Artifacts): Set of artifacts in all repos being exported

Raises:
ValidationError: When path is not in the ALLOWED_EXPORT_PATHS setting
"""
data = dict(message="Exporting Artifacts", code="export.artifacts", total=len(artifacts))
with ProgressReport(**data) as pb:
for artifact in artifacts.iterator(): # chunk_size= defaults to 2000 at a fetch
for artifact in pb.iter(artifacts):
dest = artifact.file.name
if settings.DEFAULT_FILE_STORAGE != "pulpcore.app.models.storage.FileSystem":
with tempfile.TemporaryDirectory(dir=".") as temp_dir:
Expand All @@ -112,7 +112,6 @@ def export_artifacts(export, artifacts):
export.tarfile.add(temp_file.name, dest)
else:
export.tarfile.add(artifact.file.path, dest)
pb.increment()

resource = ArtifactResource()
resource.queryset = artifacts
Expand Down
11 changes: 4 additions & 7 deletions pulpcore/app/tasks/export.py
Expand Up @@ -500,7 +500,7 @@ def _do_export(pulp_exporter, tar, the_export):
starting_versions = _get_starting_versions(do_incremental, pulp_exporter, the_export)
vers_match = _version_match(ending_versions, starting_versions)
# Gather up versions and artifacts
artifacts = None # Will be a QuerySet selecting the Artifacts that need to be exported
artifacts = set()
for version in ending_versions:
# Check version-content to make sure we're not being asked to export
# an on_demand repo
Expand All @@ -509,14 +509,11 @@ def _do_export(pulp_exporter, tar, the_export):
raise RuntimeError(_("Remote artifacts cannot be exported."))

if do_incremental:
vers_artifacts = version.artifacts.difference(vers_match[version].artifacts)
vers_artifacts = version.artifacts.difference(vers_match[version].artifacts).all()
else:
vers_artifacts = version.artifacts
vers_artifacts = version.artifacts.all()

if artifacts:
artifacts.union(vers_artifacts)
else:
artifacts = vers_artifacts
artifacts.update(vers_artifacts)

# export plugin-version-info
export_versions(the_export, plugin_version_info)
Expand Down