Project

Profile

Help

Issue #1457

closed

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

Added by mhrivnak about 8 years ago. Updated almost 5 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):
     """
Actions #1

Updated by mhrivnak about 8 years ago

  • Triaged changed from No to Yes
Actions #2

Updated by ipanova@redhat.com about 8 years ago

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

Added by pcreech about 8 years ago

Revision 6386379e | View on GitHub

Ensure file objects are cleaned up on error

Call save_and_import_content().

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

Actions #3

Updated by pcreech about 8 years ago

  • Status changed from ASSIGNED to POST

Added by pcreech about 8 years ago

Revision f1d1c092 | View on GitHub

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

Added by pcreech about 8 years ago

Revision 5b41b3fb | View on GitHub

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

Added by pcreech about 8 years ago

Revision 5b41b3fb | View on GitHub

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

Added by pcreech about 8 years ago

Revision 5b41b3fb | View on GitHub

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

Added by pcreech about 8 years ago

Revision 5b41b3fb | View on GitHub

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

Added by pcreech about 8 years ago

Revision 24a2d27e | View on GitHub

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

Added by pcreech about 8 years ago

Revision 17b437f0 | View on GitHub

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

Added by pcreech about 8 years ago

Revision 17b437f0 | View on GitHub

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

Actions #5

Updated by pcreech about 8 years ago

  • Status changed from POST to MODIFIED
Actions #6

Updated by dkliban@redhat.com about 8 years ago

  • Status changed from MODIFIED to 5
Actions #7

Updated by dkliban@redhat.com almost 8 years ago

  • Status changed from 5 to CLOSED - CURRENTRELEASE
Actions #8

Updated by bmbouter almost 5 years ago

  • Tags Pulp 2 added

Also available in: Atom PDF