prometheus-community / node-exporter-textfile-collector-scripts

Scripts for node-exporter's textfile collector
Apache License 2.0
505 stars 188 forks source link

apt_info.py: fix apt_upgrades_pending and apt_upgrades_held #207

Closed kennethso168 closed 5 months ago

kennethso168 commented 7 months ago

Fixes #193

Fixed apt_upgrades_pending always empty, as after #181, cache.upgrade(True) is no longer called in script. This call marks the packages that could be upgraded, and without it, no package has the marked_upgrade boolean set to true. Changed to filter all packages that are installed and upgradable. This should match the output of apt list --upgradable

Also fixed apt_upgrades_held including all upgradable packages including packages that are not actually held. Package can be detected to be held according to https://askubuntu.com/a/965543.

calvinbui commented 7 months ago

i can confirm the apt_upgrades_pending is now working

leahoswald commented 6 months ago

Could this be merged by anyone? Can confirm it's working too.

calvinbui commented 5 months ago

phased updates aren't working with apt_upgrades_held. the packages are listed as upgradable in apt_upgrades_pending, even though they are being kept back.

❯ sudo apt full-upgrade
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Calculating upgrade... Done
The following packages have been kept back:
  cloud-init python3-update-manager update-manager-core
0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.

image

dswarbrick commented 5 months ago

@calvinbui Please open a new issue to track the phased updates functionality. AFAIK, testing a package's state for SELSTATE_HOLD relates to packages that have been manually held, i.e. with apt-mark hold. If you know of a way to test whether a package is being held back due to being part of a phased update, please submit a PR.