Conversation
mbartmann
requested review from
a team,
bastelfreak and
smortex
as code owners
August 28, 2026 21:20
apt-mark auto|manual on a package that dpkg merely knows about ('un' or
'rc' state) does nothing yet exits 0 - and dpkg -l also exits 0 for those
states, so the current onlyif passes, the unless can never become true,
and the exec re-fires on every agent run. unhold had no guard at all.
Gate auto/manual on the package being genuinely installed via
dpkg-query's db:Status-Status, and unhold on the package actually being
held. hold keeps the loose dpkg gate deliberately: pre-holding a
not-yet-installed package is legitimate and idempotent.
Fixes puppetlabs#1166
Fixes puppetlabs#1226
mbartmann
force-pushed
the
fix-mark-idempotency
branch
from
August 28, 2026 21:35
d78314e to
70c0da9
Compare
Member
|
Running CI tests for this PR here: #1293 |
Member
|
Acceptance Test results: https://github.com/puppetlabs/puppetlabs-apt/actions/runs/33428244807?pr=1293 All green! Queued up now for engineering review when the team has availability. |
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.
Summary
Three of the four
apt::marksettings re-fire their exec on every agent run in common situations:auto/manualon a package that dpkg merely knows about (unorrcstate):apt-markdoes nothing yet exits 0 — and theonlyifguarddpkg -l <pkg>also exits 0 for those states, so the exec runs, "succeeds", theunless(apt-mark show... | grep) can never become true, and the resource is corrective forever. (apt::mark with setting auto is not idempotent #1226, and the same mechanism formanual.)unholdhad no guard at all, so it executes unconditionally on every run. (apt::mark with setting => unhold is not idempotent #1166)Changes
auto/manual: gate on the package being genuinely installed —dpkg-query --show --showformat '${db:Status-Status}' <pkg> | grep -qx installed(printsinstalledonly for stateii;config-filesforrc,not-installedforun).unhold: only run when the package is actually held —apt-mark showhold <pkg>prints the name when held and nothing otherwise.hold: deliberately unchanged.apt-mark holdon a not-yet-installed package is legitimate (pre-holding before install), sticks, and is already idempotent via the existingunless— the loosedpkg -lgate only filters names dpkg has never heard of.guard idempotencycontext asserting the exactonlyif/unlessper setting (previously unasserted).Validation
spec/defines/mark_spec.rb: 23 examples, 0 failures (Ubuntu 24.04, Ruby 3.4.7, Puppet 8.10, bundler 2.6.9). Fullspec/defines+spec/classesrun shows an identical failure set to pristinemainin the same environment (369 pre-existing environmental failures, ±0 from this change).Guard semantics verified live on Ubuntu 24.04:
dpkg -lexit 0 for anun-state package,apt-mark manualexit 0 with "can not be marked as it is not installed", and the flap disappearing with the new gate.Heads-up found while testing, not part of this PR: on Ruby 3.4 the spec harness fails to load with
Cannot determine basic system flavourunless the gemifiedsyslogstdlib gem is declared (Gemfile.localwithgem "syslog"works) — Puppet'sposix?feature requires it.Fixes #1166
Fixes #1226