Issue #9360
closedCleanup doesn't work when import_content raises exception
Description
A repo sync task failed with error:
Content import of /var/lib/pulp/working/reserved_resource_worker-4@pulp-docker04.web.prod.ext.phx2.redhat.com/005cfc84-9b50-42d2-8a04-28e60b16f5e5/sha256:801e265f146090ed6045b2d673922e7aef38bebecaeb65dba770ea84b351c6b2 failed - must be an existing file
But the unit sha256:801e265f146090ed6045b2d673922e7aef38bebecaeb65dba770ea84b351c6b2 should be removed in the task, but it's not.
Updated by gerrod over 3 years ago
Can you list some steps you took to produce this error and which version of pulp and its plugins you were using?
Updated by yuzheng over 3 years ago
Version: pulp-2.17
Reproducing steps:
- Make pulp raise error PLP0037 (Content import of %(path)s failed - must be an existing file"). It could happen when there's a bad network connection. The easiest way to reproduce the issue is updating pulp to always raise it in importing content:
https://github.com/pulp/pulp/blob/2-master/server/pulp/server/db/model/__init__.py#L921
- if not os.path.isfile(path):
+ if True:
raise exceptions.PulpCodedException(error_code=error_codes.PLP0037, path=path)
- Make a repo sync request via repositories/{REPO_ID}/actions/sync/
Expected result: repo sync task fails and no new unit is create.
Actual result: repo sync task fails as expected, but an orphan unit is created in db.
Updated by yuzheng over 3 years ago
A patch for fixing it: https://github.com/pulp/pulp/pull/4025
Added by yuzheng over 3 years ago
Updated by yuzheng over 3 years ago
- Status changed from NEW to MODIFIED
Applied in changeset pulp|e85f2b952e0d65dd292099d4c37e1de3f24d1048.
Fix clean_orphans
delete_orphan_content_units_by_type requires a list of unit ids.
Closes #9360