[sos-devel] [RFC PATCH v2] sosreport: Check for rpm database corruption during initialization

Aruna Balakrishnaiah aruna at linux.vnet.ibm.com
Wed Oct 15 09:59:11 UTC 2014


On Wednesday 15 October 2014 03:24 PM, Bryn M. Reeves wrote:
> On Wed, Oct 15, 2014 at 02:09:34PM +0530, Aruna Balakrishnaiah wrote:
>> -        if self.query_command:
>> -            pkg_list = shell_out(self.query_command).splitlines()
>> +        if self.query_command and timeout and is_executable("timeout"):
>> +            command = "timeout %ds %s" % (timeout, self.query_command)
>> +            pkg_list = shell_out(command).splitlines()
> utilities::sos_get_command_output() already handles timeouts; there's no
> need to reinvent it here. Just thread a timeout= kwarg through shell_out
> if you want to use the wrapper.
>
>>           self.valid_subclasses = [RedHatPlugin]
>>   
>> +        self.pkgs = self.package_manager.all_pkgs()
> No need to store this in the Policy object (it's already stored in
> Policy.package_manager.packages and returned from there).
>
> If you want to avoid repeated typing of
> 'self.package_manager.all_pkgs()' just store it in variable local to
> __init__.

I stored the policy because calling all_pkgs twice will be calling
the command twice so the timeout will be 600s ( 300s * 2).

To avoid that stored it as a policy. Will use a local variable instead.

Regards,
Aruna
>> +        # If rpm query timed out after timeout duration exit
>> +        if not self.pkgs:
>> +            sys.exit(1)
> For now calling exit() is fine but not without telling the user what is
> going on; I'd suggest something like "could not obtain installed package
> data" or similar.
>
> In the future I'd really like to see a fallback PackageManager
> implementation that allows us to at least retain some basic
> functionality even with a catastrophically broken package db.
>
> Regards,
> Bryn.
>




More information about the sos-devel mailing list