apt_info: don't crash where phasing_applied is missing - #272
Open
Bierchermuesli wants to merge 1 commit into
Open
Bierchermuesli wants to merge 1 commit into
Bierchermuesli wants to merge 1 commit into
Conversation
python-apt exposes the phased updates API since 2.7.11. On Debian 12 (2.6.0) and Ubuntu 22.04 (2.4.0) p.phasing_applied raises AttributeError for every package, and since _write_pending_upgrades runs first the script exits before writing any metric -- those hosts report nothing at all. Probe for the attribute rather than comparing versions: Ubuntu 24.04 backported the API into its 2.7.7, so a version check would wrongly disable phasing there. Where the attribute is missing, treat every upgrade as unphased, which is what the script did before 9784008. Signed-off-by: Stefan Grosser <13567009+Bierchermuesli@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
apt_info.pyaborts on every run wherepython-aptpredates the phased updates API, which it has exposed since 2.7.11:_write_pending_upgradesis the first writer called, so the script exits before emitting anything — affected hosts report no apt metrics at all, not just no pending-upgrade count. Introduced in 9784008 (#220), which added the filter without a guard.phasing_appliedThis probes for the attribute rather than comparing versions, because Ubuntu backported the API into noble's 2.7.7 — a version check would wrongly disable phasing on the distro where it matters most. The
hasattris resolved once at import, not per package. Where it's missing, every upgrade counts as unphased, which is what the script did before 9784008.#269 also removes these calls, but drops the feature outright and is a much larger change. This keeps it wherever the API exists and should be easy to drop if that lands first.
flake8clean. Verified on python-apt 3.1.0, and withphasing_applieddeleted from the class to simulate an older release.