From 3b17a4dcb8caa56191c5be523c874a7f470bd04a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoine=20Beaupr=C3=A9?= Date: Fri, 13 Oct 2023 11:44:17 -0400 Subject: [PATCH] do not run apt update or simulate apt dist-upgrade MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is causing all sorts of problems. The first of which is that we're hitting our poor mirrors every time the script is ran, which, in the Debian package configuration, is *every 15 minutes* (!!). The second is that this locks the cache and makes this script needlessly stumble upon a possible regression in APT from Debian bookworm and Ubuntu 22.06: https://bugs.launchpad.net/ubuntu/+source/apt/+bug/2003851 That still has to be confirmed: it's possible that `apt update` can hang for a long time, but that shouldn't concern us if we delegate this work out of band. I also do not believe actually performing the `dist-upgrade` calculations is necessary to compute the pending upgrades at all. I've done work with python-apt for other projects and haven't found that to be required: the cache has the necessary information about pending upgrades. Closes: #179 Signed-off-by: Antoine Beaupré --- apt_info.py | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/apt_info.py b/apt_info.py index eb1a642..9b1b675 100755 --- a/apt_info.py +++ b/apt_info.py @@ -10,7 +10,6 @@ import apt import collections -import contextlib import os from prometheus_client import CollectorRegistry, Gauge, generate_latest @@ -83,15 +82,6 @@ def _write_reboot_required(registry): def _main(): cache = apt.cache.Cache() - # First of all, attempt to update the index. If we don't have permission - # to do so (or it fails for some reason), it's not the end of the world, - # we'll operate on the old index. - with contextlib.suppress(apt.cache.LockFailedException, apt.cache.FetchFailedException): - cache.update() - - cache.open() - cache.upgrade(True) - registry = CollectorRegistry() _write_pending_upgrades(registry, cache) _write_held_upgrades(registry, cache)