Alert when Livepatch is broken or has stopped reporting
The alert check now also notifies, once per problem, when a host's Livepatch has been unhealthy for livepatch_alert_after_hours (default 6), or when a host that used to report Livepatch no longer does (a dead daemon leaves the agent with nothing to send). A livepatch_alerts table records which hosts have reported Livepatch, when the current problem began and whether it was notified, so hosts without Livepatch never alert and restarts do not repeat messages. Stale hosts are skipped. livepatch_problem() is now the single test for unhealthy, shared with the cover rule for pending reboots, and names the check state when that is the problem. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
203c729e14
commit
650806bfce
7 files changed
+346
-6
No files matched your search
@@ -37,6 +37,27 @@ def livepatched(days_left=300, **kw):
|
||||
return report(**fields)
|
||||
|
||||
|
||||
class LivepatchProblemTest(unittest.TestCase):
|
||||
def test_none_when_healthy_or_not_in_use(self):
|
||||
from kernelwatch.status import livepatch_problem
|
||||
self.assertIsNone(livepatch_problem(report()))
|
||||
self.assertIsNone(livepatch_problem(livepatched()))
|
||||
self.assertIsNone(livepatch_problem(livepatched(livepatch_state="nothing-to-apply")))
|
||||
|
||||
def test_describes_each_unhealthy_case(self):
|
||||
from kernelwatch.status import livepatch_problem
|
||||
self.assertEqual(livepatch_problem(livepatched(livepatch_state="apply-failed")),
|
||||
"livepatch not healthy (apply-failed, supported)")
|
||||
self.assertEqual(livepatch_problem(livepatched(livepatch_check_state="check-failed")),
|
||||
"livepatch not healthy (applied, supported, check: check-failed)")
|
||||
self.assertEqual(livepatch_problem(livepatched(livepatch_check_state=None)),
|
||||
"livepatch not healthy (applied, supported, check: ?)")
|
||||
self.assertEqual(livepatch_problem(livepatched(livepatch_supported="unsupported")),
|
||||
"livepatch not healthy (applied, unsupported)")
|
||||
self.assertEqual(livepatch_problem(livepatched(livepatch_supported=None)),
|
||||
"livepatch not healthy (applied, ?)")
|
||||
|
||||
|
||||
class LivepatchTest(unittest.TestCase):
|
||||
def evaluate(self, rep):
|
||||
return evaluate(NOW - 60, rep, NOW, CFG)
|
||||
|
||||
Reference in new issue
Block a user