[Kimchi-devel] [kimchi-devel][PATCHv3 5/6] Fix incomplete record when uploading

Aline Manera alinefm at linux.vnet.ibm.com
Tue Mar 3 15:23:54 UTC 2015


On 03/03/2015 05:13, Royce Lv wrote:
> On 02/09/2015 09:52 AM, Aline Manera wrote:
>>
>> On 28/01/2015 11:20, lvroyce at linux.vnet.ibm.com wrote:
>>> From: Royce Lv <lvroyce at linux.vnet.ibm.com>
>>>
>>> When uploading an ISO file, the ISO distro record may be incomplete 
>>> because
>>> uploading in progress.
>>> "call_stack":"Traceback (most recent call last):
>>>      File \"./src/kimchi/model/storagevolumes.py\", line 304, in lookup
>>>          iso_img = IsoImage(path)
>>>      File \"./src/kimchi/isoinfo.py\", line 149, in __init__
>>>          self._scan()
>>>      File \"./src/kimchi/isoinfo.py\", line 437, in _scan
>>>          self._scan_el_torito(data)
>>>      File \"./src/kimchi/isoinfo.py\", line 218, in _scan_el_torito
>>>          ident, csum, key55, keyAA) = self._unpack(fmt, tmp_data)
>>>      File \"./src/kimchi/isoinfo.py\", line 181, in _unpack
>>>          return s.unpack(data[:s.size])
>>>      error: unpack requires a string argument of length 32\n"
>>> So wrap reading record with error handling so that error will not occur
>>> in uploading.
>>>
>>> Signed-off-by: Royce Lv <lvroyce at linux.vnet.ibm.com>
>>> ---
>>>   src/kimchi/i18n.py    | 1 +
>>>   src/kimchi/isoinfo.py | 5 ++++-
>>>   2 files changed, 5 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/src/kimchi/i18n.py b/src/kimchi/i18n.py
>>> index af0dc4f..00e4a7d 100644
>>> --- a/src/kimchi/i18n.py
>>> +++ b/src/kimchi/i18n.py
>>> @@ -67,6 +67,7 @@ messages = {
>>>                        "to file access control lists for '%(user)s' 
>>> user if possible, or add the "
>>>                        "'%(user)s' to the ISO path group, or (not 
>>> recommended) 'chmod -R o+x 'path_to_iso'."
>>>                        "Details: %(err)s" ),
>>
>>> +    "KCHISO0009E": _("Incomplete record while reading ISO 
>>> %(filename)s."),
>>
>> Why and when will the user get this error message?
> This is when self._scan() trying to read the el_torito and primary 
> volume but only part of data has been written.
>>
>> If it is uploading a file and want to see its progress we should be 
>> smart enough to do not flood the user with errors.
> User won't be flooded with this error, previous error is raised when 
> calling storagevolume lookup, when wrapped with ISOFormatError, 
> storagevolume lookup will ignore this error and report this volume 
> distro and version as "unknown".
>             try:
>                 iso_img = IsoImage(path)
>                 os_distro, os_version = iso_img.probe()
>                 bootable = True
>             except IsoFormatError:
>                 bootable = False

Good! Thanks for explaining! =)

>
>>
>>>       "KCHIMG0001E": _("An error occurred when probing image OS 
>>> information."),
>>>       "KCHIMG0002E": _("No OS information found in given image."),
>>> diff --git a/src/kimchi/isoinfo.py b/src/kimchi/isoinfo.py
>>> index 1e36a6d..18aa38e 100644
>>> --- a/src/kimchi/isoinfo.py
>>> +++ b/src/kimchi/isoinfo.py
>>> @@ -147,7 +147,10 @@ class IsoImage(object):
>>>           self.remote = self._is_iso_remote()
>>>           self.volume_id = None
>>>           self.bootable = False
>>> -        self._scan()
>>> +        try:
>>> +            self._scan()
>>> +        except:
>>> +            raise IsoFormatError('KCHISO0009E', {'filename': 
>>> self.path})
>>>
>>>       def _is_iso_remote(self):
>>>           if os.path.isfile(self.path):
>>
>




More information about the Kimchi-devel mailing list