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

Rodrigo Trujillo rodrigo.trujillo at linux.vnet.ibm.com
Tue Mar 25 20:06:39 UTC 2014


On 03/25/2014 03:45 PM, Aline Manera wrote:
> On 03/24/2014 05:53 PM, Rodrigo Trujillo wrote:
>> 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 | 8 +++++---
>>   3 files changed, 12 insertions(+), 5 deletions(-)
>>
>> diff --git a/src/kimchi/asynctask.py b/src/kimchi/asynctask.py
>> index 8f0d96c..33e9ba1 100644
>> --- a/src/kimchi/asynctask.py
>> +++ b/src/kimchi/asynctask.py
>> @@ -59,8 +59,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):
>>           try:
>> diff --git a/src/kimchi/i18n.py b/src/kimchi/i18n.py
>> index 81a74c4..ab01160 100644
>> --- a/src/kimchi/i18n.py
>> +++ b/src/kimchi/i18n.py
>> @@ -32,6 +32,7 @@ messages = {
>>       "KCHAPI0007E": _("This API only supports"),
>>
>>       "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 due error: %(err)s"),
>
> I think I've already seen this message before.
> Try to reuse the existent messages.
> If they are common use KCHAPI[XXXXX]

ACK
>
>>
>>       "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 fea19f6..a3a9e25 100644
>> --- a/src/kimchi/model/storagepools.py
>> +++ b/src/kimchi/model/storagepools.py
>> @@ -158,10 +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):
>>       def __init__(self, **kargs):
>
> _______________________________________________
> Kimchi-devel mailing list
> Kimchi-devel at ovirt.org
> http://lists.ovirt.org/mailman/listinfo/kimchi-devel
>




More information about the Kimchi-devel mailing list