Project

Profile

Help

Issue #1457

unit.import_content() failure leaves file-less unit in DB

Added by mhrivnak about 5 years ago. Updated almost 2 years ago.

Status:
CLOSED - CURRENTRELEASE
Priority:
Normal
Assignee:
Category:
-
Sprint/Milestone:
-
Start date:
Due date:
Estimated time:
Severity:
2. Medium
Version:
Master
Platform Release:
2.8.0
OS:
Triaged:
Yes
Groomed:
No
Sprint Candidate:
No
Tags:
Pulp 2
Sprint:
Quarter:

Description

Plugins used to move a unit's files into place and then save the unit in the DB. With 2.8, this had to be reversed.

So if the import_content() call fails, the unit will be left in the database without having files. This is a difficult state to recover from.

A potential solution is to help plugins attempt to undo the save if the import_content call fails. Something like this on FileUnit might work:

diff --git a/server/pulp/server/db/model/__init__.py b/server/pulp/server/db/model/__init__.py
index a6ba85b..6d2454f 100644
--- a/server/pulp/server/db/model/__init__.py
+++ b/server/pulp/server/db/model/__init__.py
@@ -761,6 +761,14 @@ class FileContentUnit(ContentUnit):
         with FileStorage() as storage:
             storage.put(self, path, location)

+    def save_and_import_content(self, path, location=None):
+        self.save()
+        try:
+            self.import_content(path, location)
+        except Exception:
+            self.delete()
+            raise
+

 class SharedContentUnit(ContentUnit):
     """

Associated revisions

Revision 6386379e View on GitHub
Added by pcreech about 5 years ago

Ensure file objects are cleaned up on error

Call save_and_import_content().

re #1457 https://pulp.plan.io/issues/1457

Revision f1d1c092 View on GitHub
Added by pcreech about 5 years ago

Ensure file objects are cleaned up on error

Call save_and_import_content().

Utilize cleanup pattern instead where usage doesn't fit.

re #1457 https://pulp.plan.io/issues/1457

Revision 5b41b3fb View on GitHub
Added by pcreech about 5 years ago

Ensure file objects are cleaned up on error

Call save_and_import_content().

Utilize cleanup pattern instead where usage doesn't fit.

re #1457 https://pulp.plan.io/issues/1457

Revision 5b41b3fb View on GitHub
Added by pcreech about 5 years ago

Ensure file objects are cleaned up on error

Call save_and_import_content().

Utilize cleanup pattern instead where usage doesn't fit.

re #1457 https://pulp.plan.io/issues/1457

Revision 5b41b3fb View on GitHub
Added by pcreech about 5 years ago

Ensure file objects are cleaned up on error

Call save_and_import_content().

Utilize cleanup pattern instead where usage doesn't fit.

re #1457 https://pulp.plan.io/issues/1457

Revision 5b41b3fb View on GitHub
Added by pcreech about 5 years ago

Ensure file objects are cleaned up on error

Call save_and_import_content().

Utilize cleanup pattern instead where usage doesn't fit.

re #1457 https://pulp.plan.io/issues/1457

Revision 24a2d27e View on GitHub
Added by pcreech about 5 years ago

Ensure file objects are cleaned up on error

Call save_and_import_content().

Utilize cleanup pattern instead where usage doesn't fit.

re #1457 https://pulp.plan.io/issues/1457

Revision 17b437f0 View on GitHub
Added by pcreech about 5 years ago

Ensure file objects are cleaned up on error

Plugins save then call import_content on FileContentUnit objects. This ensures that if an error happens on import_content, we also clean up after ourselves.

re #1457 https://pulp.plan.io/issues/1457

Revision 17b437f0 View on GitHub
Added by pcreech about 5 years ago

Ensure file objects are cleaned up on error

Plugins save then call import_content on FileContentUnit objects. This ensures that if an error happens on import_content, we also clean up after ourselves.

re #1457 https://pulp.plan.io/issues/1457

History

#1 Updated by mhrivnak about 5 years ago

  • Triaged changed from No to Yes

#2 Updated by ipanova@redhat.com about 5 years ago

  • Status changed from NEW to ASSIGNED
  • Assignee set to pcreech

#3 Updated by pcreech about 5 years ago

  • Status changed from ASSIGNED to POST

#5 Updated by pcreech about 5 years ago

  • Status changed from POST to MODIFIED

#6 Updated by dkliban@redhat.com almost 5 years ago

  • Status changed from MODIFIED to 5

#7 Updated by dkliban@redhat.com almost 5 years ago

  • Status changed from 5 to CLOSED - CURRENTRELEASE

#8 Updated by bmbouter almost 2 years ago

  • Tags Pulp 2 added

Please register to edit this issue

Also available in: Atom PDF