Flag hosts whose OS release no longer gets security updates
CI / tests (Python 3.10) (pull_request) Successful in 30s
CI / tests (Python 3.11) (pull_request) Successful in 30s
CI / tests (Python 3.12) (pull_request) Successful in 28s
CI / tests (Python 3.13) (pull_request) Successful in 28s
CI / lint (pull_request) Successful in 3s

Past its end of support a release gets no more security updates, so apt
offers nothing and the host showed ok indefinitely. The server now has a
table of when free security support ends for each release the agent
installs on (support.py): Debian's LTS end, and Ubuntu's end of standard
support plus end of ESM. Dates from Debian LTS and Ubuntu's release cycle
via endoflife.date; a test checks the table covers every release
agent/install.sh accepts.

The agent reports whether Ubuntu Pro is attached and esm-infra's status,
read from the pro client's world-readable status.json. A host past its
date goes to update; within os_eol_warn_days (default 90) of it, the row
gets a note. An Ubuntu host with ESM enabled isn't warned when standard
support ends, only before ESM does. The host page shows the dates.
Agent 0.7.0; older agents don't report ESM and count as having none.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
patrickandClaude Opus 5.5 committed 2026-10-31 19:50:44 -04:00
1 parent 5a11d31e66
commit bc46c55298
15 files changed
+348 -7

No files matched your search

+108
View File
@@ -0,0 +1,108 @@
"""OS end-of-support: the release table and what it says about a host."""
import os
import re
import unittest
from datetime import date
from helpers import REPO
from kernelwatch import support
def host(os_id, version, **kw):
return {"os_id": os_id, "os_version_id": version, **kw}
def check(rep, today, warn_days=90):
return support.check(rep, date.fromisoformat(today), warn_days)
class ReleaseTableTest(unittest.TestCase):
def test_every_release_the_agent_installs_on_is_listed(self):
with open(os.path.join(REPO, "agent", "install.sh")) as f:
accepted = re.search(r'^case "\$ID:\$VERSION_ID" in\n(.*?)\)', f.read(), re.M | re.S).group(1)
releases = [tuple(r.strip().split(":")) for r in accepted.split("|")]
self.assertGreaterEqual(len(releases), 5)
for key in releases:
self.assertIn(key, support.RELEASES)
def test_dates_are_consistent(self):
for key, rel in support.RELEASES.items():
with self.subTest(key=key):
if key[0] == "ubuntu":
self.assertIsNotNone(rel.esm_end)
self.assertLess(rel.end, rel.esm_end)
else:
self.assertIsNone(rel.esm_end)
class DebianTest(unittest.TestCase):
def test_supported(self):
self.assertIsNone(check(host("debian", "12"), "2026-10-31"))
def test_warning_before_the_end(self):
self.assertEqual(check(host("debian", "12"), "2028-05-01"),
(False, "Debian 12 security support ends 2028-06-30 (in 60 days); plan the upgrade"))
self.assertEqual(check(host("debian", "12"), "2028-06-30"),
(False, "Debian 12 security support ends 2028-06-30 (in 0 days); plan the upgrade"))
def test_warning_disabled(self):
self.assertIsNone(check(host("debian", "12"), "2028-05-01", warn_days=0))
def test_ended(self):
self.assertEqual(check(host("debian", "11"), "2026-10-31"),
(True, "Debian 11 security support ended 2026-08-31; upgrade the release"))
self.assertEqual(check(host("debian", "11"), "2026-10-31", warn_days=0)[0], True,
"the warning setting never hides an ended release")
class UbuntuTest(unittest.TestCase):
def test_supported(self):
self.assertIsNone(check(host("ubuntu", "24.04"), "2026-10-31"))
self.assertIsNone(check(host("ubuntu", "22.04"), "2026-10-31"))
def test_standard_support_ending_without_esm(self):
why = ("Ubuntu 22.04 standard support ends 2027-06-01 (in 31 days); "
"enable ESM with Ubuntu Pro or plan the upgrade")
self.assertEqual(check(host("ubuntu", "22.04"), "2027-05-01"), (False, why))
self.assertEqual(check(host("ubuntu", "22.04", ubuntu_esm_infra="disabled"), "2027-05-01"), (False, why))
def test_standard_support_ending_with_esm_is_fine(self):
self.assertIsNone(check(host("ubuntu", "22.04", ubuntu_esm_infra="enabled"), "2027-05-01"))
def test_standard_support_ended_without_esm(self):
self.assertEqual(check(host("ubuntu", "20.04", ubuntu_pro_attached=False), "2026-10-31"),
(True, "Ubuntu 20.04 standard support ended 2025-05-31 and ESM isn't enabled; "
"enable it with Ubuntu Pro or upgrade the release"))
def test_standard_support_ended_with_esm(self):
self.assertIsNone(check(host("ubuntu", "20.04", ubuntu_esm_infra="enabled"), "2026-10-31"))
self.assertEqual(check(host("ubuntu", "20.04", ubuntu_esm_infra="enabled"), "2030-03-01"),
(False, "Ubuntu 20.04 ESM ends 2030-04-23 (in 53 days); plan the upgrade"))
def test_esm_ended(self):
self.assertEqual(check(host("ubuntu", "20.04", ubuntu_esm_infra="enabled"), "2030-04-24"),
(True, "Ubuntu 20.04 ESM ended 2030-04-23; upgrade the release"))
class OtherHostsTest(unittest.TestCase):
def test_unknown_release_is_noted(self):
self.assertEqual(check(host("ubuntu", "25.10"), "2026-10-31"),
(False, "no end-of-support date known for ubuntu 25.10"))
def test_nothing_said_without_a_release(self):
self.assertIsNone(check({}, "2026-10-31"), "agent reported no os fields")
self.assertIsNone(check(host("debian", ""), "2026-10-31"), "Debian testing/sid")
self.assertIsNone(check(host("fedora", "41"), "2026-10-31"))
def test_summary(self):
self.assertEqual(support.summary(host("debian", "13")), "until 2030-06-30")
self.assertEqual(support.summary(host("ubuntu", "24.04", ubuntu_esm_infra="enabled")),
"standard until 2029-05-31, ESM until 2034-04-25 (esm-infra: enabled)")
self.assertEqual(support.summary(host("ubuntu", "24.04")),
"standard until 2029-05-31, ESM until 2034-04-25 (esm-infra: unknown)")
self.assertIsNone(support.summary(host("ubuntu", "25.10")))
if __name__ == "__main__":
unittest.main()