Compare commits

...
2 Commits
Author SHA1 Message Date
patrick 6cbc9665d8 Merge pull request 'Flag hosts whose OS release no longer gets security updates' (#26) from feat/os-end-of-support into main
CI / tests (Python 3.10) (push) Successful in 29s
CI / tests (Python 3.11) (push) Successful in 29s
CI / tests (Python 3.12) (push) Successful in 29s
CI / tests (Python 3.13) (push) Successful in 29s
CI / lint (push) Successful in 4s
Reviewed-on: #26
2026-10-31 23:53:27 +00:00
patrickandClaude Opus 5.5 bc46c55298 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>
2026-10-31 19:50:44 -04:00
15 changed files with 348 additions and 7 deletions

No files matched your search

+1 -1
View File
@@ -29,7 +29,7 @@ Each host gets one status. When several apply, the worst one wins:
|----------|---------|
| `stale` | No report in `stale_after_hours` (default 3h), or never. Other data can't be trusted. |
| `reboot` | A newer kernel is installed but not running, or `/run/reboot-required` exists. |
| `update` | A kernel or security update is available but not installed, services are running outdated libraries and need a restart, or apt's package lists are too old, or apt itself fails, so "no updates" can't be trusted. Also when `/boot` is too full for the next kernel, or dpkg left packages half-installed. |
| `update` | A kernel or security update is available but not installed, services are running outdated libraries and need a restart, or apt's package lists are too old, or apt itself fails, so "no updates" can't be trusted. Also when `/boot` is too full for the next kernel, dpkg left packages half-installed, or the OS release no longer gets security updates. |
| `ok` | Running the newest installed kernel, with no security or kernel updates pending. |
Each row lists the reasons behind its status, and clicking a host shows its full
+28 -2
View File
@@ -6,7 +6,7 @@
# rules can change without redeploying agents.
set -euo pipefail
AGENT_VERSION=0.6.0
AGENT_VERSION=0.7.0
# Prefix for every file the agent reads. Only the test suite sets this.
ROOT=${KERNELWATCH_ROOT:-}
@@ -261,6 +261,25 @@ unfinished_packages() {
sort -u || true
}
# Ubuntu Pro state from the pro client's status cache, which it keeps
# world-readable (the token lives in private/ next to it). Prints "ATTACHED ESM"
# (e.g. "true enabled", "false -"); nothing if there's no file or it can't be
# read, as on Debian. Past standard support, only esm-infra keeps main patched.
PRO_STATUS_FILE=$ROOT/var/lib/ubuntu-advantage/status.json
ubuntu_pro() {
[[ -r $PRO_STATUS_FILE ]] || return 0
command -v python3 >/dev/null || return 0
python3 -I -c '
import json, re, sys
d = json.load(open(sys.argv[1]))
attached = d.get("attached") is True
esm = next((s.get("status") for s in d.get("services") or []
if isinstance(s, dict) and s.get("name") == "esm-infra"), None)
esm = esm if attached and isinstance(esm, str) and re.fullmatch(r"[a-z/-]{1,20}", esm) else "-"
print("true" if attached else "false", esm)
' "$PRO_STATUS_FILE" 2>/dev/null || true
}
uptime_seconds() {
local up _
[[ -r $ROOT/proc/uptime ]] || return 0
@@ -270,7 +289,7 @@ uptime_seconds() {
build_report() {
local running newest kernels sim inst sim_err rc apt_ok=1 apt_err='' reboot_file=0 reboot_pkgs=
local boot_size='' boot_free=''
local boot_size='' boot_free='' pro_attached='' pro_esm=''
running=$(uname -r)
kernels=$(installed_kernels)
@@ -295,6 +314,8 @@ build_report() {
fi
read -r boot_size boot_free <<<"$(boot_space)" || true
read -r pro_attached pro_esm <<<"$(ubuntu_pro)" || true
[[ $pro_esm == - ]] && pro_esm=
printf '{'
printf '"agent_version":%s,' "$(json_str "$AGENT_VERSION")"
@@ -335,6 +356,11 @@ build_report() {
printf '"boot_size_kb":%s,' "$(json_int "$boot_size")"
printf '"boot_free_kb":%s,' "$(json_int "$boot_free")"
printf '"dpkg_unfinished_packages":%s,' "$(unfinished_packages | json_str_array)"
case $pro_attached in
true | false) printf '"ubuntu_pro_attached":%s,' "$pro_attached" ;;
*) printf '"ubuntu_pro_attached":null,' ;;
esac
printf '"ubuntu_esm_infra":%s,' "$(json_str_or_null "$pro_esm")"
printf '"apt_lists_age_seconds":%s,' "$(json_int "$(apt_lists_age)")"
printf '"uptime_seconds":%s' "$(json_int "$(uptime_seconds)")"
printf '}\n'
+17 -1
View File
@@ -10,7 +10,7 @@ Each host gets one status. When several apply, the worst one wins:
|----------|---------|
| `stale` | No report in `stale_after_hours` (default 3h), or never. Other data can't be trusted. |
| `reboot` | A newer kernel is installed but not running, or `/run/reboot-required` exists. |
| `update` | A kernel or security update is available but not installed, services are running outdated libraries and need a restart, or apt's package lists are too old (`apt_stale_after_hours`) for "no updates" to mean anything. Also when `/boot` has less than `boot_min_free_mb` free, or dpkg left packages half-installed. |
| `update` | A kernel or security update is available but not installed, services are running outdated libraries and need a restart, or apt's package lists are too old (`apt_stale_after_hours`) for "no updates" to mean anything. Also when `/boot` has less than `boot_min_free_mb` free, dpkg left packages half-installed, or the OS release no longer gets security updates. |
| `ok` | Running the newest installed kernel, with no security or kernel updates pending. |
Each row also lists the reasons behind its status, and clicking a host shows
@@ -92,6 +92,22 @@ How the agent works it out:
host: `sudo dpkg --configure -a` (after freeing space, if that was the cause).
A report taken while apt is mid-install can show this briefly; the next one
clears it. Agents before 0.6.0 send neither field and are judged as before.
- **OS end of support**: once a release stops getting security updates, apt
never offers one again, so the host would show `ok` indefinitely. The server
knows when each supported release's free security support ends
(`server/kernelwatch/support.py`): for Debian, the end of
[LTS](https://wiki.debian.org/LTS), which carries on from regular security
support through the same repository; for Ubuntu, the end of standard support,
or with [ESM](https://ubuntu.com/security/esm) (`esm-infra`, part of Ubuntu Pro,
free for personal use) the end of ESM. The agent reads whether ESM is on from the
Ubuntu Pro client's public status file, `/var/lib/ubuntu-advantage/status.json`.
A host past its date is in `update` ("Debian 11 security support ended
2026-08-31"); in the `os_eol_warn_days` (default 90) before it, the row gets a
note. An Ubuntu host with ESM enabled gets no warning when standard support
ends, only before ESM does. The host page shows the dates. They're a table in
the server, so they need a kernelwatch update when a new release ships;
a release the table doesn't know is noted. Agents before 0.7.0 don't report
ESM, so an Ubuntu host on one counts as having none.
- **Fresh package lists**: the simulation only knows what apt's package lists
say, and the agent can't refresh them itself. Ubuntu refreshes them about once
a day. Debian doesn't by default unless `unattended-upgrades` is set up, so a
+1 -1
View File
@@ -4,4 +4,4 @@ __version__ = "0.4.0"
# Version of agent/kernelwatch-agent shipped alongside this server; older agents
# are noted on the dashboard. tests/test_status.py checks the two stay in sync.
AGENT_VERSION = "0.6.0"
AGENT_VERSION = "0.7.0"
+6
View File
@@ -33,6 +33,10 @@ class Config:
# Less free space than this on /boot's filesystem puts a host in update: the next
# kernel (image plus initramfs, often over 100 MB) may not fit. 0 disables.
boot_min_free_mb: int = 200
# Note a host this many days before its OS release stops getting security updates
# (or Ubuntu standard support ends without ESM). 0 disables the warning; a host
# past the date is in update either way.
os_eol_warn_days: int = 90
# Where `scheduled-backup` (kernelwatch-backup.timer) writes dated copies of the
# database, and how many days of them it keeps; 0 keeps them all. It must stay
@@ -96,6 +100,8 @@ def load(path: str | None = None) -> Config:
raise SystemExit(f"{path}: ntfy_timeout_seconds must be positive and finite")
if cfg.report_min_interval_seconds < 0:
raise SystemExit(f"{path}: report_min_interval_seconds must be zero or positive")
if cfg.os_eol_warn_days < 0:
raise SystemExit(f"{path}: os_eol_warn_days must be zero or positive")
if cfg.boot_min_free_mb < 0:
raise SystemExit(f"{path}: boot_min_free_mb must be zero or positive")
if cfg.backup_keep_days < 0:
+2
View File
@@ -45,6 +45,8 @@ FIELDS: dict[str, str] = {
"boot_size_kb": "int",
"boot_free_kb": "int",
"dpkg_unfinished_packages": "strlist",
"ubuntu_pro_attached": "bool",
"ubuntu_esm_infra": "str",
"apt_lists_age_seconds": "int",
"uptime_seconds": "int",
}
+9 -1
View File
@@ -15,7 +15,7 @@ from dataclasses import dataclass, field
from datetime import date, datetime, timezone
from typing import Any
from . import AGENT_VERSION
from . import AGENT_VERSION, support
from .config import Config
LEVELS = ("stale", "reboot", "update", "ok")
@@ -229,6 +229,14 @@ def evaluate(received_at: int | None, report: dict[str, Any] | None, now: float,
if low := boot_space_low(report, cfg):
status.raise_to("update", low)
today = datetime.fromtimestamp(now, timezone.utc).date()
if found := support.check(report, today, cfg.os_eol_warn_days):
problem, why = found
if problem:
status.raise_to("update", why)
else:
status.note(why)
if services := report.get("services_need_restart"):
shown = ", ".join(s.removesuffix(".service") for s in services[:5])
more = f", +{len(services) - 5} more" if len(services) > 5 else ""
+98
View File
@@ -0,0 +1,98 @@
"""When each supported OS release stops getting security updates.
A host past that date shows `ok` forever, because no updates will ever arrive to
flag. So the status check compares the host's release (`os_id`, `os_version_id`)
with the dates below.
Sources: the Debian security team and Debian LTS (wiki.debian.org/LTS) and
Ubuntu's release cycle (ubuntu.com/about/release-cycle), as collected by
endoflife.date. Add each new release when it ships; tests/test_support.py checks
that every release the agent supports is listed.
"""
from __future__ import annotations
from dataclasses import dataclass
from datetime import date
from typing import Any
@dataclass(frozen=True)
class Release:
name: str
# Debian: end of LTS, the last free security support (regular security support
# ends about two years earlier and LTS continues it from the same repository).
# Ubuntu: end of standard support for the main archive.
end: date
# Ubuntu only: end of Expanded Security Maintenance (esm-infra, part of Ubuntu
# Pro), which keeps patching main after standard support ends.
esm_end: date | None = None
RELEASES: dict[tuple[str, str], Release] = {
("debian", "11"): Release("Debian 11", date(2026, 8, 31)),
("debian", "12"): Release("Debian 12", date(2028, 6, 30)),
("debian", "13"): Release("Debian 13", date(2030, 6, 30)),
("ubuntu", "20.04"): Release("Ubuntu 20.04", date(2025, 5, 31), date(2030, 4, 23)),
("ubuntu", "22.04"): Release("Ubuntu 22.04", date(2027, 6, 1), date(2032, 4, 21)),
("ubuntu", "24.04"): Release("Ubuntu 24.04", date(2029, 5, 31), date(2034, 4, 25)),
("ubuntu", "26.04"): Release("Ubuntu 26.04", date(2031, 5, 29), date(2036, 4, 23)),
}
def release(report: dict[str, Any]) -> Release | None:
return RELEASES.get((report.get("os_id") or "", report.get("os_version_id") or ""))
def _esm(report: dict[str, Any]) -> bool:
return report.get("ubuntu_esm_infra") == "enabled"
def check(report: dict[str, Any], today: date, warn_days: int) -> tuple[bool, str] | None:
"""(is it a problem, why) about this host's OS support, or None if there's nothing to say.
A problem means no security updates are coming: the release is past its last
support date, or an Ubuntu release is past standard support without ESM. The
rest are warnings for the `warn_days` before such a date (0 disables them)."""
os_id, version = report.get("os_id"), report.get("os_version_id")
if os_id not in ("debian", "ubuntu") or not version:
return None # Debian testing/sid has no VERSION_ID; other distros aren't supported
rel = release(report)
if rel is None:
return False, f"no end-of-support date known for {os_id} {version}"
def soon(day: date) -> int | None:
left = (day - today).days
return left if warn_days and 0 <= left <= warn_days else None
if rel.esm_end is None:
if today > rel.end:
return True, f"{rel.name} security support ended {rel.end}; upgrade the release"
if (left := soon(rel.end)) is not None:
return False, f"{rel.name} security support ends {rel.end} (in {left} days); plan the upgrade"
return None
if today > rel.esm_end:
return True, f"{rel.name} ESM ended {rel.esm_end}; upgrade the release"
if _esm(report):
if today > rel.end and (left := soon(rel.esm_end)) is not None:
return False, f"{rel.name} ESM ends {rel.esm_end} (in {left} days); plan the upgrade"
return None
if today > rel.end:
return True, (f"{rel.name} standard support ended {rel.end} and ESM isn't enabled; "
"enable it with Ubuntu Pro or upgrade the release")
if (left := soon(rel.end)) is not None:
return False, (f"{rel.name} standard support ends {rel.end} (in {left} days); "
"enable ESM with Ubuntu Pro or plan the upgrade")
return None
def summary(report: dict[str, Any]) -> str | None:
"""The host page's one-line view of the release's support dates."""
rel = release(report)
if rel is None:
return None
if rel.esm_end is None:
return f"until {rel.end}"
esm = report.get("ubuntu_esm_infra")
return f"standard until {rel.end}, ESM until {rel.esm_end} (esm-infra: {esm or 'unknown'})"
+2 -1
View File
@@ -19,7 +19,7 @@ from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
from typing import Any
from urllib.parse import parse_qs, quote, unquote, urlsplit
from . import __version__, auth, db
from . import __version__, auth, db, support
from .config import Config
from .report import MAX_BODY_BYTES, ReportError, sanitize
from .status import LEVELS, Status, evaluate
@@ -490,6 +490,7 @@ class Handler(BaseHTTPRequestHandler):
if latest else None),
field("Reported hostname", r.get("reported_hostname")),
field("OS", r.get("os_pretty_name")),
field("OS security support", support.summary(r)),
field("Running kernel", r.get("kernel_running"), code=True),
field("Kernel build", r.get("kernel_build"), code=True),
field("Running kernel package", r.get("kernel_running_pkg_version"), code=True),
+5
View File
@@ -19,6 +19,11 @@ report_retention_days = 30
# fails half-way. 0 disables.
boot_min_free_mb = 200
# A host whose OS release no longer gets security updates (Debian past LTS, Ubuntu
# past standard support without ESM) is in "update". This many days before that,
# its row gets a note. 0 disables the note.
os_eol_warn_days = 90
# kernelwatch-backup.timer writes a dated copy of the database here every night
# and deletes copies this many days old or older (0 keeps them all). Keep the
# directory under /var/lib/kernelwatch; the unit can't write elsewhere. Copy the
+40
View File
@@ -173,9 +173,49 @@ class AgentReportTest(AgentCase):
f.write("ii \tcurl\nrc \told-pkg\n")
self.assertEqual(self.report()["dpkg_unfinished_packages"], [])
def write_pro_status(self, text):
d = os.path.join(self.root, "var/lib/ubuntu-advantage")
os.makedirs(d, exist_ok=True)
with open(os.path.join(d, "status.json"), "w") as f:
f.write(text)
def test_ubuntu_pro_attached_with_esm(self):
self.write_pro_status(json.dumps({"attached": True, "services": [
{"name": "esm-apps", "status": "enabled"}, {"name": "esm-infra", "status": "enabled"},
{"name": "livepatch", "status": "enabled"}]}))
r = self.report()
self.assertEqual((r["ubuntu_pro_attached"], r["ubuntu_esm_infra"]), (True, "enabled"))
def test_ubuntu_pro_attached_esm_disabled(self):
self.write_pro_status(json.dumps({"attached": True, "services": [
{"name": "esm-infra", "status": "disabled"}]}))
r = self.report()
self.assertEqual((r["ubuntu_pro_attached"], r["ubuntu_esm_infra"]), (True, "disabled"))
def test_ubuntu_pro_not_attached(self):
# Unattached, the cache lists services as available, which isn't the same as on.
self.write_pro_status(json.dumps({"attached": False, "services": [
{"name": "esm-infra", "available": "yes", "status": "enabled"}]}))
r = self.report()
self.assertEqual((r["ubuntu_pro_attached"], r["ubuntu_esm_infra"]), (False, None))
def test_no_pro_client_or_unreadable_status(self):
r = self.report()
self.assertEqual((r["ubuntu_pro_attached"], r["ubuntu_esm_infra"]), (None, None))
self.write_pro_status("{not json")
r = self.report()
self.assertEqual((r["ubuntu_pro_attached"], r["ubuntu_esm_infra"]), (None, None))
def test_odd_esm_status_is_dropped(self):
self.write_pro_status(json.dumps({"attached": True, "services": [
{"name": "esm-infra", "status": "en abled\" x"}]}))
r = self.report()
self.assertEqual((r["ubuntu_pro_attached"], r["ubuntu_esm_infra"]), (True, None))
def test_every_reported_field_is_accepted_by_the_server(self):
from kernelwatch.report import FIELDS
self.write_livepatch("LIVEPATCH-STATE: applied\nLIVEPATCH-FIXES: 2\n")
self.write_pro_status('{"attached": true, "services": [{"name": "esm-infra", "status": "enabled"}]}')
self.assertEqual(sorted(set(self.report()) - set(FIELDS)), [])
def write_conf(self, text):
+8
View File
@@ -100,6 +100,14 @@ class ConfigTest(unittest.TestCase):
with self.subTest(bad=bad), self.assertRaises(SystemExit):
config.load(self.write(tmp, f"boot_min_free_mb = {bad}\n"))
def test_os_eol_warn_days_validated(self):
with tempdir() as tmp:
self.assertEqual(config.Config().os_eol_warn_days, 90)
self.assertEqual(config.load(self.write(tmp, "os_eol_warn_days = 0\n")).os_eol_warn_days, 0)
for bad in ("-1", "1.5"):
with self.subTest(bad=bad), self.assertRaises(SystemExit):
config.load(self.write(tmp, f"os_eol_warn_days = {bad}\n"))
def test_fallback_parser_matches_tomllib(self):
"""Python 3.10 has no tomllib; the fallback must read the same configs."""
if config.tomllib is None:
+13
View File
@@ -339,6 +339,19 @@ class EvaluateTest(unittest.TestCase):
self.assertEqual(self.level(report(dpkg_unfinished_packages=[])).level, "ok")
self.assertEqual(self.level(report(dpkg_unfinished_packages=None)).level, "ok")
def test_os_past_end_of_support(self):
s = self.level(report(os_id="debian", os_version_id="11"))
self.assertEqual(s.level, "update")
self.assertIn("Debian 11 security support ended 2026-08-31", s.reasons[0])
def test_os_end_of_support_warning_is_a_note(self):
# NOW is 2027-01-15; Ubuntu 22.04 standard support ends 2027-06-01.
rep = report(os_id="ubuntu", os_version_id="22.04")
self.assertEqual(evaluate(NOW, rep, NOW, Config(os_eol_warn_days=200)).level, "ok")
self.assertIn("standard support ends 2027-06-01",
evaluate(NOW, rep, NOW, Config(os_eol_warn_days=200)).reasons[0])
self.assertEqual(self.level(rep).reasons, [], "outside the default 90 days")
def test_reboot_outranks_update(self):
s = self.level(report(needrestart_ksta=3, security_count=2))
self.assertEqual(s.level, "reboot")
+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()
+10
View File
@@ -197,6 +197,16 @@ class DashboardTest(ServerCase):
self.assertIn("<code>linux-image-6.8.0-138-generic</code>", body)
self.assertIn("/boot has 95 MB free, 81% used; the next kernel may not fit", body)
def test_host_page_shows_os_support(self):
self.add_user("admin", "a-long-password")
token = self.add_host("web01")
self.post_report(token, {"kernel_running": "6.8.0-136-generic", "apt_lists_age_seconds": 60,
"os_id": "ubuntu", "os_version_id": "24.04", "ubuntu_pro_attached": True,
"ubuntu_esm_infra": "enabled"})
_, headers, _ = self.login("admin", "a-long-password")
body = self.request("GET", "/host/web01", headers={"Cookie": headers["Set-Cookie"].split(";")[0]})[2]
self.assertIn("standard until 2029-05-31, ESM until 2034-04-25 (esm-infra: enabled)", body)
def test_login_dashboard_logout(self):
self.add_user("admin", "a-long-password")
token = self.add_host("web01")