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

Bryn M. Reeves bmr at redhat.com
Wed Oct 15 09:54:36 UTC 2014


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__.

> +        # 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