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

Division by zero during Pulp import #4777

Closed
dralley opened this issue Nov 27, 2023 · 4 comments · Fixed by #4792
Closed

Division by zero during Pulp import #4777

dralley opened this issue Nov 27, 2023 · 4 comments · Fixed by #4792
Assignees

Comments

@dralley
Copy link
Contributor

dralley commented Nov 27, 2023

Version
3.36.0+

Describe the bug

During a Katello test run, the following exception was encountered

 {"traceback"=>"  File \"/usr/lib/python3.11/site-packages/pulpcore/tasking/tasks.py\", line 61, in _execute_task\n    result = func(*args, **kwargs)\n             ^^^^^^^^^^^^^^^^^^^^^\n  File \"/usr/lib/python3.11/site-packages/pulpcore/app/tasks/importer.py\", line 453, in pulp_import\n    with tarfile.open(path, \"r\", fileobj=fp) as tar:\n         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File \"/usr/lib64/python3.11/tarfile.py\", line 1815, in open\n    fileobj.seek(saved_pos)\n  File \"/usr/lib/python3.11/site-packages/pulpcore/app/tasks/importer.py\", line 132, in seek\n    self.chunk = target // self.chunk_size\n                 ~~~~~~~^^~~~~~~~~~~~~~~~~\n", "description"=>"integer division or modulo by zero"} (Katello::Errors::Pulp3Error)

I'm not 100% certain, but I suspect the cause here is that if chunks aren't used during the export, chunk_size is set to 0:

https://github.com/pulp/pulpcore/blob/main/pulpcore/app/tasks/export.py#L456C31-L456C31

and ChunkedFile reads that value here:

https://github.com/pulp/pulpcore/blob/main/pulpcore/app/tasks/importer.py#L79

and we're using ChunkedFile even in the non-chunked case so long as a TOC file was provided.

https://github.com/pulp/pulpcore/blob/main/pulpcore/app/tasks/importer.py#L335-L336

To Reproduce

I would expect it to be reproducible if performing a non-chunked export, and providing a TOC path for the import.

Expected behavior

We should never see an integer division by zero error.

Additional context

@dralley
Copy link
Contributor Author

dralley commented Nov 27, 2023

We'll also want to expand our tests to cover this

@mdellweg
Copy link
Member

Does this mean that we can provide a toc file that makes a non-chunked import look like one with a single chunk, only the specified chunk-size is wrong?

@dralley dralley self-assigned this Nov 28, 2023
dralley added a commit to dralley/pulpcore that referenced this issue Nov 29, 2023
@tannermsmith1
Copy link

Thank you for working to address this! We started seeing this on our team about 3 weeks ago on our Pulp 3 servers. We haven't been able to import content to an air-gapped Pulp 3 server since upgrading past 3.36.0. We export the content non-chunked.

@pulpbot
Copy link
Member

pulpbot commented Dec 11, 2023

dralley added a commit to dralley/pulpcore that referenced this issue Dec 13, 2023
And clean up vestigial code

closes pulp#4777
dralley added a commit to dralley/pulpcore that referenced this issue Dec 13, 2023
And clean up vestigial code

closes pulp#4777
ggainey pushed a commit that referenced this issue Dec 14, 2023
And clean up vestigial code

closes #4777
patchback bot pushed a commit that referenced this issue Dec 14, 2023
And clean up vestigial code

closes #4777

(cherry picked from commit 5f6fe99)
patchback bot pushed a commit that referenced this issue Dec 14, 2023
And clean up vestigial code

closes #4777

(cherry picked from commit 5f6fe99)
dralley added a commit that referenced this issue Dec 14, 2023
And clean up vestigial code

closes #4777

(cherry picked from commit 5f6fe99)
dralley added a commit that referenced this issue Dec 14, 2023
And clean up vestigial code

closes #4777

(cherry picked from commit 5f6fe99)
sdherr pushed a commit to sdherr/pulpcore that referenced this issue Jan 10, 2024
And clean up vestigial code

closes pulp#4777
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

5 participants