[packagekit] yum2 error fixes
Tim Lauridsen
tim.lauridsen at googlemail.com
Fri Feb 15 11:30:32 PST 2008
Robin Norwood wrote:
> On Thu, 14 Feb 2008 12:46:09 -0500
> Robin Norwood <rnorwood at redhat.com> wrote:
>
>> On Thu, 14 Feb 2008 07:41:37 +0000
>> Richard Hughes <hughsient at gmail.com> wrote:
>>
>>> In the yum2 backend we have loads of these:
>>>
>>> except yum.Errors.InstallError,e:
>>> msgs = ';'.join(e)
>>> self.ErrorCode(ERROR_PACKAGE_ALREADY_INSTALLED,msgs)
>>> self.Exit()
>>>
>>> i.e. in an error, send error code, and exit the script.
>>>
>>> What we probably need to do is:
>>>
>>> Not fatal errors (i.e. the script can continue):
>>>
>>> self.ErrorCode(ERROR_PACKAGE_ALREADY_INSTALLED,"foo")
>>> self.Finished(EXIT_FAILED)
>>> return
>>>
>>> and for fatal errors:
>>>
>>> self.ErrorCode(ERROR_INTERNAL_ERROR,"foo")
>>> self.Finished(EXIT_FAILED)
>>> self.Exit()
>>>
>>> I think we are exiting quite a bit without needing to - and we
>>> certainly need to send finished else bad things happen to the
>>> daemon.
>> Yeah, I'll fix this today. A result of me just copying the existing
>> behavior wholesale.
>
> Ok, these are fixed.
>
> Now, the only time when we actually exit on error is when we catch an
> exception and decide that the 'yum cache is invalid'.
>
> except yum.Errors.RepoError,e:
> self.ErrorCode(ERROR_NO_CACHE,"Yum cache is invalid")
> self.Finished(EXIT_FAILED)
> self.Exit()
>
> We do this whenever we get a RepoError - a couple of questions for the
> yum guys:
>
> o Is 'yum cache invalid' a correct description for any RepoError, or
> are there other error cases that throw RepoErrors?
>
RepoError is raised, if there is something wrong with metadate, i
cacheonly mode, then it is because some need metadata is missing.
There is some other cases when not in cacheonly mode, but this is
thing we cant solve any way. (Ex. bad configuration i .repo files)
> o Is there anything we can do inside PK to recover from this?
We can refreshcache and try again.
>
> o It looks like we wait 200 seconds to get a yum lock:
>
> def doLock(self):
> ''' Lock Yum'''
> retries = 0
> while not self.isLocked():
> try: # Try to lock yum
> self.yumbase.doLock( YUM_PID_FILE )
> PackageKitBaseBackend.doLock(self)
> except:
> if retries == 0:
> self.StatusChanged(STATUS_WAIT)
> time.sleep(2)
> retries += 1
> if retries > 100:
> self.ErrorCode(ERROR_INTERNAL_ERROR,'Yum is locked
> by another application') self.Finished(EXIT_FAILED)
> return
>
> That seems a bit long to expect the user to wait. Any objections to me
> lowering the retry limit to, say 20?
Fine with me.
>
> Also, I ended up having to change the semantics of _runYumTransaction()
> so that it returns False upon failure, and True upon success. This is
> because the old version called Exit() and killed the process. I'm not
> sure that this is particularly pythonic, so if anyone has a better
> suggestion, have at it.
>
Sound fine to me.
Tim
More information about the PackageKit
mailing list