[Kimchi-devel] [PATCH V5 4/5] Fix 'disk full' issue: Fix storagepool and asynctasks error handling

Rodrigo Trujillo rodrigo.trujillo at linux.vnet.ibm.com
Wed Apr 2 20:12:08 UTC 2014


This patch fixes the error handling when storagepool.py and asynctask.py
try to update the objectstore (database) with task and scanning
information.

Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo at linux.vnet.ibm.com>
---
 src/kimchi/asynctask.py          | 7 +++++--
 src/kimchi/i18n.py               | 2 ++
 src/kimchi/model/storagepools.py | 7 +++++--
 3 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/src/kimchi/asynctask.py b/src/kimchi/asynctask.py
index b54f143..713b91f 100644
--- a/src/kimchi/asynctask.py
+++ b/src/kimchi/asynctask.py
@@ -60,8 +60,11 @@ class AsyncTask(object):
         obj = {}
         for attr in ('id', 'target_uri', 'message', 'status'):
             obj[attr] = getattr(self, attr)
-        with self.objstore as session:
-            session.store('task', self.id, obj)
+        try:
+            with self.objstore as session:
+                session.store('task', self.id, obj)
+        except Exception as e:
+            raise OperationFailed('KCHASYNC0002E', {'err': e.message})
 
     def _run_helper(self, opaque, cb):
         cherrypy.serving.request = self._cp_request
diff --git a/src/kimchi/i18n.py b/src/kimchi/i18n.py
index 4f11e8a..86ab5d6 100644
--- a/src/kimchi/i18n.py
+++ b/src/kimchi/i18n.py
@@ -32,6 +32,7 @@ messages = {
     "KCHAPI0007E": _("This API only supports JSON"),
 
     "KCHASYNC0001E": _("Datastore is not initiated in the model object."),
+    "KCHASYNC0002E": _("Unable to start task due error: %(err)s"),
 
     "KCHAUTH0001E": _("Authentication failed for user '%(userid)s'. [Error code: %(code)s]"),
     "KCHAUTH0002E": _("You are not authorized to access Kimchi"),
@@ -146,6 +147,7 @@ messages = {
     "KCHPOOL0034E": _("Unable to deactivate pool %(name)s as it is associated with some templates"),
     "KCHPOOL0035E": _("Unable to delete pool %(name)s as it is associated with some templates"),
     "KCHPOOL0036E": _("A volume group named '%(name)s' already exists. Please, choose another name to create the logical pool."),
+    "KCHPOOL0037E": _("Unable to update database with deep scan information due error: %(err)s"),
 
     "KCHVOL0001E": _("Storage volume %(name)s already exists"),
     "KCHVOL0002E": _("Storage volume %(name)s does not exist in storage pool %(pool)s"),
diff --git a/src/kimchi/model/storagepools.py b/src/kimchi/model/storagepools.py
index 92b2496..5af33b7 100644
--- a/src/kimchi/model/storagepools.py
+++ b/src/kimchi/model/storagepools.py
@@ -158,9 +158,12 @@ class StoragePoolsModel(object):
         task_id = add_task('', self.scanner.start_scan, self.objstore,
                            scan_params)
         # Record scanning-task/storagepool mapping for future querying
-        with self.objstore as session:
+        try:
+            with self.objstore as session:
                 session.store('scanning', params['name'], task_id)
-        return task_id
+            return task_id
+        except Exception as e:
+            raise OperationFailed('KCHPOOL0037E', {'err': e.message})
 
 
 class StoragePoolModel(object):
-- 
1.8.5.3




More information about the Kimchi-devel mailing list