Report when kernelwatch's own helper units keep failing
kernelwatch-apt-update.service failed hourly on most hosts for weeks without anything showing it. The agent only Wants= its helper units, so the report goes out regardless, with stale lists or (for needrestart) results that quietly turn "unknown". Each helper (apt-update, needrestart) now runs kernelwatch-unit-result as its ExecStopPost=, which systemd runs after failed runs too. It writes "RESULT EXIT_CODE EXIT_STATUS FAILURES" to /run/kernelwatch/<name>.result, FAILURES counting failed runs in a row. The agent (0.10.0) reports results from the last two hours as helper_units. On the server, one or two failures are a note (an admin's apt can hold the lock now and then); three in a row put the host in update, naming the unit and its exit status and pointing at journalctl. The host page gets a "kernelwatch helpers" row. The Livepatch unit isn't tracked: it fails by design where the snap is installed but Livepatch isn't enabled, and Livepatch has its own check. The apt-update unit now has RuntimeDirectory=kernelwatch (preserved, like the others) for its result file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ad310a4948
commit
f88261d2f5
18 files changed
+303
-8
No files matched your search
@@ -527,6 +527,21 @@ X
|
||||
self.assertIsNone(r["security_repo_suite"])
|
||||
self.assertIsNone(r["security_repo_age_seconds"])
|
||||
|
||||
def test_helper_units(self):
|
||||
self.write_root("run/kernelwatch/apt-update.result", "exit-code exited 100 3\n")
|
||||
self.write_root("run/kernelwatch/needrestart.result", "success exited 0 0\n")
|
||||
self.write_root("run/kernelwatch/livepatch.result", "exit-code exited 1 9\n") # not a tracked helper
|
||||
self.assertEqual(self.report()["helper_units"],
|
||||
["apt-update exit-code exited 100 3", "needrestart success exited 0 0"])
|
||||
|
||||
def test_helper_units_stale_or_garbled_results_ignored(self):
|
||||
self.write_root("run/kernelwatch/apt-update.result", "exit-code exited 100 3\n", age=3 * 3600)
|
||||
self.write_root("run/kernelwatch/needrestart.result", 'exit-code exited 1 "x\n')
|
||||
self.assertEqual(self.report()["helper_units"], [])
|
||||
|
||||
def test_no_helper_results(self):
|
||||
self.assertEqual(self.report()["helper_units"], [])
|
||||
|
||||
def test_send_without_config_fails_cleanly(self):
|
||||
proc = self.run_agent()
|
||||
self.assertNotEqual(proc.returncode, 0)
|
||||
|
||||
Reference in new issue
Block a user