GoogleCloudPlatform / osconfig

Apache License 2.0
84 stars 100 forks source link

pip list --format=legacy is invalid #148

Closed ghost closed 4 years ago

ghost commented 4 years ago

Inventory for pip fails due to use of removed format 'legacy' for pip list. Pip list format legacy support was removed in pip 18.0

https://github.com/GoogleCloudPlatform/osconfig/blob/27a85d59cc833fed7372ab0da24f27aa93d386ee/inventory/packages/pip.go#L27-L30

Error when manually invoking

$ /usr/bin/pip list --format=legacy
WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.
Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.
To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.

Usage:   
  pip list [options]

option --format: invalid choice: 'legacy' (choose from 'columns', 'freeze', 'json')

Errors logged by OS Config Agent

Jan 31 14:21:42 intel-20200131-090105 OSConfigAgent[675]: 2020-01-31T14:21:42.1294Z OSConfigAgent Error inventory.go:82: packages.GetInstalledPackages() error: error listing installed pip packages: exit status 2
Jan 31 14:21:45 intel-20200131-090105 OSConfigAgent[675]: 2020-01-31T14:21:45.1943Z OSConfigAgent Error inventory.go:87: packages.GetPackageUpdates() error: error getting pip updates: exit status 2
adjackura commented 4 years ago

Thanks for creating the issue. Can I ask what distro and version you are using, how you installed pip, what your general use case for pip is (vs distro package managers), and whether you find support for pip in osconfig useful?

I ask because supporting a tool that does not have a stable api across versions is complicated and I need to decide if we simply drop support entirely or just support the latest version.

ghost commented 4 years ago

I came across this in Debian 9, specifically one of the AI Platform Notebooks images:

gcloud compute images list --project deeplearning-platform-release --no-standard-images --filter name:common-cpu-notebooks-20200127
NAME                           PROJECT                        FAMILY                DEPRECATED  STATUS
common-cpu-notebooks-20200127  deeplearning-platform-release  common-cpu-notebooks              READY

Pip is installed on the image out of the box. For my use case I have no preference on the pip reporting, I was interested in the software recipes functionality and the inventory's pip logs served as a red herring while trying to work with them. They also end up taking over the osconfig agent's logs as the pip command fails repeatedly every 10 minutes which makes it more difficult to monitor for failures when applying software recipes.

adjackura commented 4 years ago

For easier debugging I would suggest leveraging cloud logging as that would allow you to filter out logs that aren't useful. Also if you have issues with software recipe debugging feel free to open another issue, I know that piece of the agent is lacking in logs right now. As far as this issue goes, I'll update the logic a bit to work the the latest versions of pip so as not to break any existing uses but also decrease the logging severity so as not to spam.