Repository navigation
feat(apt): report unattended-upgrades status - #807
vladimirrott merged 10 commits into
Conversation
Signed-off-by: Danny Ward <[email protected]>
Signed-off-by: Danny Ward <[email protected]>
Signed-off-by: Danny Ward <[email protected]>
Signed-off-by: Danny Ward <[email protected]>
Signed-off-by: Danny Ward <[email protected]>
Signed-off-by: Danny Ward <[email protected]>
vladimirrott
left a comment
There was a problem hiding this comment.
Thanks for #680. The fence-test exception is the part I'd have worried about, and you closed it off: UBUNTU_ONLY_SHARED_DEBIAN_ACTIONS fails unless its member is Debian-shaped, sits in UBUNTU_ONLY_ACTIONS and stays out of DEBIAN_ONLY_ACTIONS, so nobody can widen the exception without the test noticing. Keeping the prompt block inside the Ubuntu branch of render_debian_prompt, and leaving out the dry run that takes the apt lock, both match the issue.
Reviewed at ec72aa9246ae3faf03abc7f9c0caf398257938bc. I ran nothing from this branch on my own machine; everything below ran in containers with --network=none. The baseline is right (2150 = main's 2145 + your 5 tests) and all six commits carry a sign-off.
I ran the parser tests (cargo test -p sysknife-daemon --lib --locked --offline unattended_upgrades, 6 selected) against one mutant at a time:
[pristine] 6 passed rc=0
[M1-missing-log-reads-ok] unattended_upgrades_parser_reports_missing_log_directory_as_unknown ... FAILED rc=101
[M2-missing-config-defaults-enabled] 6 passed rc=0
[M3-zero-reads-enabled] unattended_upgrades_parser_reports_zero_as_off ... FAILED rc=101
[M4-disabled-branch-skipped] 6 passed rc=0
[pristine-again] 6 passed rc=0
Blocking, two items.
-
On a packaged install the log line always reads "no timestamped log entry". The daemon runs as
User=sysknife(packaging/sysknife-daemon.service:8), andpackaging/sysknife-sysusers.confadds that user tosystemd-journalonly. Ubuntu ships the log directory asdrwxr-x--- root:adm. I ran your script's text, copied verbatim fromUNATTENDED_UPGRADES_STATUS_SCRIPT, in a container with that layout, once as root and once as asysknifeuser outsideadm:drwxr-x--- root:adm /var/log/unattended-upgrades uid=999(sysknife) gid=999(sysknife) groups=999(sysknife) === as root __SYSKNIFE_LOG_BEGIN__ 2026-11-17 06:05:00,123 INFO Starting unattended upgrades script __SYSKNIFE_LOG_END__ === as sysknife (not in adm) __SYSKNIFE_LOG_BEGIN__ __SYSKNIFE_LOG_END__The directory exists, the glob cannot list it,
zcatfails into/dev/null, and the parser turns the empty section intounknown (/var/log/unattended-upgrades: no timestamped log entry). "Unknown" is right, but the reason sends the operator looking for a log problem when the daemon lacked permission to read it. Please have the script check[ -r "$log_dir" ] && [ -x "$log_dir" ]and print a marker of its own when that fails, have the parser report the directory as not readable by the daemon user, and add a test for that marker. The__NO_LOG_FILES__arm in the parser has no producer in the script today, so this is a good moment to either emit it or drop it.Reading the entry itself would take
admmembership for the daemon user, and that grants everyadm-readable log on the host. That is a trust-boundary call I'd rather make separately, so leave it out of this PR. -
A missing
20auto-upgradeshas no test. #680 asks for exactly this: "Make the parser default a missing value to 'enabled' and that test must go red." M2 does that (theNonearm pushes1 (enabled)), and all six tests pass. A fixture with__MISSING_CONFIG__in the config section, assertingunknown (/etc/apt/apt.conf.d/20auto-upgrades: file missing or unreadable)for both keys, covers it.
Optional:
- M4 survives because the general arm prints the same text for a disabled timer that
list-timersstill lists. The special arm only changes the output whenlist-timershas no row for the unit ("n/a" in place of "unknown"). Either test that case or drop the arm. - No test reaches the parse hook in
execute_spec(if output.is_success() && spec.action_name == "UnattendedUpgradesStatus");git grepfinds the name in no executor test. Without that hook the operator gets the raw__SYSKNIFE_*sections. A test that runsexecute_specon anActionSpecnamedUnattendedUpgradesStatuswhose command prints your fixture would pin it.
Thanks again; once the two items are in I'll rerun the mutants at the new head.
Signed-off-by: Vladimir Rotariu <[email protected]>
The daemon runs as the sysknife user, which is not in adm, so on a packaged Ubuntu install it cannot list /var/log/unattended-upgrades. The status script now tests that the directory is readable and searchable and prints __UNREADABLE_LOG_DIR__ when it is not. The parser turns that marker into "directory not readable by the daemon user" instead of "no timestamped log entry", which sent operators looking for a log problem. The daemon user gains no new group membership. The __NO_LOG_FILES__ arm had no producer in the script, so it is removed. New tests cover the unreadable marker and the script's access check, a missing 20auto-upgrades for both keys, a disabled timer with no list-timers row, and the UnattendedUpgradesStatus parse hook in execute_spec. docs/action-reference.md is regenerated because it embeds the script text, and the workspace test count moves from 2146 to 2156 (the PR's 5 tests plus these 5). Signed-off-by: Vladimir Rotariu <[email protected]>
vladimirrott
left a comment
There was a problem hiding this comment.
@dannyward630 Thank you for #807. Both blocking items from my last review are in, on your branch, so this could land without another round. Your commits are untouched.
Reviewed at 63ee30f6.
- Unreadable log directory. The script now tests
[ -r "$log_dir" ] && [ -x "$log_dir" ]and prints__UNREADABLE_LOG_DIR__when the daemon cannot list it. The parser reportsunknown (/var/log/unattended-upgrades: directory not readable by the daemon user). The__NO_LOG_FILES__arm had no producer, so it is gone. I added noadmmembership; that stays a separate decision. - Missing
20auto-upgrades. A new test feeds__MISSING_CONFIG__and assertsunknown (...: file missing or unreadable)for both keys. - Optional items, both taken. A test for a disabled timer with no
list-timersrow, and anexecute_spectest that pins theUnattendedUpgradesStatusparse hook. docs/action-reference.mdchanged by one line because it embeds the script text. The workspace baseline is main's count plus your 5 tests and my 5.
I ran your script text from the new head in a debian:12-slim container, offline, with the real layout (drwxr-x--- root:adm):
ROOT: 2026-11-17 06:05:00,123 INFO x
SYSKNIFE: __UNREADABLE_LOG_DIR__
The gate ran the new parser test against one mutant:
receipt recorded for #807 at 63ee30f6 (observed: clean pass, mutated fail)
I'll merge once the board is green and write the CHANGELOG line myself.
Signed-off-by: Vladimir Rotariu <[email protected]> # Conflicts: # tests/evidence/workspace-tests.json
vladimirrott
left a comment
There was a problem hiding this comment.
Re-approving at 0cb23e34. Main moved (#797, #806, #750, #748 landed), so I merged it into the branch and set tests/evidence/workspace-tests.json to 2160: main's 2150 plus the 10 tests this PR adds. When I merge the head I verified (63ee30f6) with today's main and diff that against this head, only the evidence file differs. The gate receipt from 63ee30f6 still applies. I'll merge when the board is green.
vladimirrott
left a comment
There was a problem hiding this comment.
Re-approving at 6cdc4551 after the last update from main. The gate reran the parser test against the same mutant at this head: receipt recorded for #807 at 6cdc4551 (observed: clean pass, mutated fail). Nothing else changed since 0cb23e34.
Summary
Adds
UnattendedUpgradesStatus, a Low-risk Ubuntu Observer action reporting bothAPT::Periodicvalues, last and next runs for both apt-daily timers, and the newest timestamped unattended-upgrades log entry. Missing settings, timers, and logs remain unknown and identify the missing path or unit. It is read-only and does not run a dry-run.Wires the action into the catalogue, executor, Ubuntu-only prompt, preview policy, and MCP Observer allow-list.
Related Issue
Closes #680.
Validation
git commit -s.Local checks:
cargo fmt --all --checkand Bash-npassed. The focusedcargo nextestcommand could not reach tests on this Windows host because the workspace'svsockdependency fails to compile against Unix-only APIs. The repository CI runs on Linux.Notes for Reviewers
The parser reports missing inputs as unknown with their path or timer name. No apt-locking dry-run is performed.
Assisted by Codex (GPT-6). The full diff was reviewed.