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

Compression monkeypatch is not always being loaded #4351

Closed
dralley opened this issue Sep 4, 2023 · 0 comments · Fixed by #4352
Closed

Compression monkeypatch is not always being loaded #4351

dralley opened this issue Sep 4, 2023 · 0 comments · Fixed by #4352

Comments

@dralley
Copy link
Contributor

dralley commented Sep 4, 2023

Describe the bug

For whatever reason, the monkeypatch added in #3884 is not always loaded. I'm not 100% sure if it has to do with the order in which the files are loaded into the interpreter or some other detail, but we need to make it reliable.

To Reproduce

This patch

diff --git a/pulpcore/app/monkeypatch.py b/pulpcore/app/monkeypatch.py
index 38852f6a7..94ec14fb6 100644
--- a/pulpcore/app/monkeypatch.py
+++ b/pulpcore/app/monkeypatch.py
@@ -49,6 +49,8 @@ if sys.version_info.major == 3 and sys.version_info.minor < 12:
         _Stream is intended to be used only internally.
         """
 
+        is_patched = True
+
         def _init_write_gz(self):
             """Initialize for writing with gzip compression."""
             self.cmp = self.zlib.compressobj(
diff --git a/pulpcore/app/tasks/export.py b/pulpcore/app/tasks/export.py
index 3259187d9..c013d0283 100644
--- a/pulpcore/app/tasks/export.py
+++ b/pulpcore/app/tasks/export.py
@@ -191,6 +191,9 @@ def fs_publication_export(exporter_pk, publication_pk, start_repo_version_pk=Non
         exporter_pk (str): FilesystemExporter pk
         publication_pk (str): Publication pk
     """
+    if not hasattr(tarfile._Stream, "is_patched"):
+        raise RuntimeError("tarfile module was not patched properly")
+
     exporter = Exporter.objects.get(pk=exporter_pk).cast()
     publication = Publication.objects.get(pk=publication_pk).cast()
 
@@ -235,6 +238,9 @@ def fs_repo_version_export(exporter_pk, repo_version_pk, start_repo_version_pk=N
         exporter_pk (str): FilesystemExporter pk
         repo_version_pk (str): RepositoryVersion pk
     """
+    if not hasattr(tarfile._Stream, "is_patched"):
+        raise RuntimeError("tarfile module was not patched properly")
+
     exporter = Exporter.objects.get(pk=exporter_pk).cast()
     repo_version = RepositoryVersion.objects.get(pk=repo_version_pk)
     start_repo_version = None
@@ -387,6 +393,9 @@ def pulp_export(exporter_pk, params):
     the_export.validated_start_versions = serializer.validated_data.get("start_versions", None)
     the_export.validated_chunk_size = serializer.validated_data.get("chunk_size", None)
 
+    if not hasattr(tarfile._Stream, "is_patched"):
+        raise RuntimeError("tarfile module was not patched properly")
+
     try:
         the_export.task = Task.current()
 

Expected behavior
A clear and concise description of what you expected to happen.

Additional context
Add any other context about the problem here. Please provide links to any previous discussions via Discourse or Bugzilla.

dralley added a commit to dralley/pulpcore that referenced this issue Sep 4, 2023
dralley added a commit to dralley/pulpcore that referenced this issue Sep 4, 2023
ipanova pushed a commit that referenced this issue Sep 4, 2023
patchback bot pushed a commit that referenced this issue Sep 4, 2023
closes #4351

(cherry picked from commit 876eb7f)
patchback bot pushed a commit that referenced this issue Sep 4, 2023
closes #4351

(cherry picked from commit 876eb7f)
patchback bot pushed a commit that referenced this issue Sep 4, 2023
closes #4351

(cherry picked from commit 876eb7f)
patchback bot pushed a commit that referenced this issue Sep 4, 2023
closes #4351

(cherry picked from commit 876eb7f)
patchback bot pushed a commit that referenced this issue Sep 4, 2023
closes #4351

(cherry picked from commit 876eb7f)
patchback bot pushed a commit that referenced this issue Sep 4, 2023
closes #4351

(cherry picked from commit 876eb7f)
mdellweg pushed a commit that referenced this issue Sep 4, 2023
closes #4351

(cherry picked from commit 876eb7f)
mdellweg pushed a commit that referenced this issue Sep 4, 2023
closes #4351

(cherry picked from commit 876eb7f)
mdellweg pushed a commit that referenced this issue Sep 4, 2023
closes #4351

(cherry picked from commit 876eb7f)
mdellweg pushed a commit that referenced this issue Sep 4, 2023
closes #4351

(cherry picked from commit 876eb7f)
mdellweg pushed a commit that referenced this issue Sep 4, 2023
closes #4351

(cherry picked from commit 876eb7f)
mdellweg pushed a commit that referenced this issue Sep 4, 2023
closes #4351

(cherry picked from commit 876eb7f)
patchback bot pushed a commit that referenced this issue Sep 13, 2023
closes #4351

(cherry picked from commit 876eb7f)
patchback bot pushed a commit that referenced this issue Sep 13, 2023
closes #4351

(cherry picked from commit 876eb7f)
dralley added a commit that referenced this issue Sep 13, 2023
closes #4351

(cherry picked from commit 876eb7f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant