This bug has been migrated to another issue tracking site. It has been closed here and may no longer be being monitored.

If you would like to get updates for this issue, or to participate in it, you may do so at Red Hat Issue Tracker .
Red Hat Satellite engineering is moving the tracking of its product development work on Satellite to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "Satellite project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs will be migrated starting at the end of May. If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "Satellite project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/SAT-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 2266075 - Cannot import chunked export if the resulted tarball is smaller than chunk size
Summary: Cannot import chunked export if the resulted tarball is smaller than chunk size
Keywords:
Status: CLOSED MIGRATED
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Pulp
Version: 6.14.1
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: Unspecified
Assignee: satellite6-bugs
QA Contact: Satellite QE Team
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2024-02-26 16:11 UTC by Joniel Pasqualetto
Modified: 2024-06-06 17:24 UTC (History)
3 users (show)

Fixed In Version: pulpcore-3.39.0
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2024-06-06 17:24:43 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker   SAT-23573 0 None Migrated None 2024-06-06 17:24:41 UTC

Description Joniel Pasqualetto 2024-02-26 16:11:24 UTC
Description of problem:

When exporting content using chunks, if the resulting exported content is smaller than the chunk size, the import fails with the following error:


~~~
 {"traceback"=>"  File \"/usr/lib/python3.9/site-packages/pulpcore/tasking/pulpcore_worker.py\", line 460, in execute_task\n    result = func(*args, **kwargs)\n  File \"/usr/lib/python3.9/site-packages/pulpcore/app/tasks/importer.py\", line 478, in pulp_import\n    with tarfile.open(path, read_mode) as tar:\n  File \"/usr/lib64/python3.9/tarfile.py\", line 1817, in open\n    return func(name, filemode, fileobj, **kwargs)\n  File \"/usr/lib64/python3.9/tarfile.py\", line 1863, in gzopen\n    fileobj = GzipFile(name, mode + \"b\", compresslevel, fileobj)\n  File \"/usr/lib64/python3.9/gzip.py\", line 173, in __init__\n    fileobj = self.myfileobj = builtins.open(filename, mode or 'rb')\n", "description"=>"[Errno 2] No such file or directory: '/var/lib/pulp/imports/2.0/2024-02-26T10-34-29-05-00/export-7a3b71e4-8acb-4c32-a473-cb08ef899047-20240226_1534.tar.gz'"}
~~~

Version-Release number of selected component (if applicable):

Satellite 6.12
Satellite 6.13
Satellite 6.14


How reproducible:

Always


Steps to Reproduce:

1. Chose a small repository to export (example: satellite-client-6-for-rhel-9-x86_64-rpms, it generates a 67Mb tarball)

2. Export it using a chunk bigger than the repo size (use 1GB for example):

~~~
hammer content-export complete repository --id 17 --chunk-size-gb 1
~~~

3. Check the result toc file:

~~~
# cat export-0d7bc5de-77e3-4113-8de3-4fc2f99bad2d-20240226_1531-toc.json|jq
{
  "meta": {
    "chunk_size": 1073741824,
    "file": "export-0d7bc5de-77e3-4113-8de3-4fc2f99bad2d-20240226_1531.tar.gz",
    "global_hash": "de2f14f337e48291b2cba8e7d04d08c3b60b578378072a106be77668c46d9010",
    "checksum_type": "sha256"
  },
  "files": {
    "export-0d7bc5de-77e3-4113-8de3-4fc2f99bad2d-20240226_1531.tar.gz.0000": "de2f14f337e48291b2cba8e7d04d08c3b60b578378072a106be77668c46d9010"
  }
}
~~~

4. Try importing it:

~~~
# hammer content-import repository --organization-id 1 --path $(pwd)
[....................................................................................................................................................................................................................................] [100%]
Error: 1 subtask(s) failed for task group /pulp/api/v3/task-groups/4665687d-3fb3-48fe-bab5-fd3e45988f70/.
Errors:
 {"traceback"=>"  File \"/usr/lib/python3.9/site-packages/pulpcore/tasking/pulpcore_worker.py\", line 460, in execute_task\n    result = func(*args, **kwargs)\n  File \"/usr/lib/python3.9/site-packages/pulpcore/app/tasks/importer.py\", line 478, in pulp_import\n    with tarfile.open(path, read_mode) as tar:\n  File \"/usr/lib64/python3.9/tarfile.py\", line 1817, in open\n    return func(name, filemode, fileobj, **kwargs)\n  File \"/usr/lib64/python3.9/tarfile.py\", line 1863, in gzopen\n    fileobj = GzipFile(name, mode + \"b\", compresslevel, fileobj)\n  File \"/usr/lib64/python3.9/gzip.py\", line 173, in __init__\n    fileobj = self.myfileobj = builtins.open(filename, mode or 'rb')\n", "description"=>"[Errno 2] No such file or directory: '/var/lib/pulp/imports/2.0/2024-02-26T10-34-29-05-00/export-7a3b71e4-8acb-4c32-a473-cb08ef899047-20240226_1534.tar.gz'"}
~~~

Actual results:

Import fails saying it can't find the tar.gz file

Expected results:

Import should process the toc properly and identify that there is a "chunked" file, rename it to the expected tarball name and import.


Additional info:

This used to work on previous versions.

Problem is here:

vim /usr/lib/python3.9/site-packages/pulpcore/app/tasks/importer.py +456

~~~
448     def validate_and_assemble(toc_filename):
449         """Validate checksums of, and reassemble, chunks in table-of-contents file."""
450         the_toc = validate_toc(toc_filename)
451         toc_dir = os.path.dirname(toc_filename)
452         result_file = os.path.join(toc_dir, the_toc["meta"]["file"])
453 
454         # if we have only one entry in "files", it must be the full .tar.       <===== this is not actually true
455         # Return the filename from the meta-section.
456         if len(the_toc["files"]) == 1:
457             return result_file
458 
459         # We have multiple chunks. Reassemble them and return the result.
460         return reassemble(the_toc, toc_dir, result_file)

~~~

Could be a quick fix as replacing line 456 for this:

 ~~~
# git diff
diff --git a/importer.py b/importer.py
index 4edcba8..77f1663 100644
--- a/importer.py
+++ b/importer.py
@@ -453,7 +453,7 @@ def pulp_import(importer_pk, path, toc, create_repositories):
 
         # if we have only one entry in "files", it must be the full .tar.
         # Return the filename from the meta-section.
-        if len(the_toc["files"]) == 1:
+        if len(the_toc["files"]) == 1 and the_toc["meta"]["chunk_size"] == 0:
             return result_file
 
         # We have multiple chunks. Reassemble them and return the result.
 ~~~
 
I would propose a PR with that, but I see that latest upstream code is already different and I think this issue will not happen on that newer code.  It would be nice to have a fix downstream soon.

This affects 6.12, 6.13 and 6.14.

Used to work on 6.11

Comment 2 Daniel Alley 2024-03-27 03:41:30 UTC
Yes, as far as I can tell, this ought to work fine on Satellite 6.15.  At least it seems to work fine upstream after we did a rewrite of some related code.

The backport, if there is one, will need to be entirely different code though. Should we have separate bugs filed?

Comment 8 Eric Helms 2024-06-06 17:24:43 UTC
This BZ has been automatically migrated to the issues.redhat.com Red Hat Issue Tracker. All future work related to this report will be managed there.

Due to differences in account names between systems, some fields were not replicated.  Be sure to add yourself to Jira issue's "Watchers" field to continue receiving updates and add others to the "Need Info From" field to continue requesting information.

To find the migrated issue, look in the "Links" section for a direct link to the new issue location. The issue key will have an icon of 2 footprints next to it, and begin with "SAT-" followed by an integer.  You can also find this issue by visiting https://issues.redhat.com/issues/?jql= and searching the "Bugzilla Bug" field for this BZ's number, e.g. a search like:

"Bugzilla Bug" = 1234567

In the event you have trouble locating or viewing this issue, you can file an issue by sending mail to rh-issues. You can also visit https://access.redhat.com/articles/7032570 for general account information.


Note You need to log in before you can comment on or make changes to this bug.