Give phased updates their own dashboard column #4
No files matched your search
@@ -9,7 +9,7 @@ fleet is running its newest kernel, has updates waiting, or needs a reboot.
|
||||
ingest API and a login-protected dashboard. You don't need pip, a venv or a
|
||||
build step.
|
||||
|
||||
Supported: agents on **Debian 12/13** and **Ubuntu 22.04/24.04 LTS**; server on
|
||||
Supported: agents on **Debian 12/13** and **Ubuntu 22.04/24.04/26.04 LTS**; server on
|
||||
**Debian 12+** or **Ubuntu 22.04+** (the system `python3`, 3.10 or newer).
|
||||
|
||||
```
|
||||
@@ -66,7 +66,8 @@ How the agent works it out:
|
||||
- **Phased updates** (Ubuntu only): Ubuntu rolls some updates out gradually and
|
||||
holds them back from a share of machines at first. apt doesn't offer these to
|
||||
the host yet, so they aren't counted as available updates. They appear as
|
||||
`+N phased` in the Updates column, with the package list on the host page.
|
||||
their own Phased column (hover for the packages, `–` on Debian), with the
|
||||
list also on the host page.
|
||||
They never affect status, because Ubuntu doesn't phase security updates and
|
||||
there's nothing to act on until apt offers them.
|
||||
- **Package list freshness**: the mtime of apt's update stamps. The agent
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@ done
|
||||
# shellcheck source=/dev/null
|
||||
. /etc/os-release
|
||||
case "$ID:$VERSION_ID" in
|
||||
debian:12 | debian:13 | ubuntu:22.04 | ubuntu:24.04) ;;
|
||||
debian:12 | debian:13 | ubuntu:22.04 | ubuntu:24.04 | ubuntu:26.04) ;;
|
||||
*) echo "warning: untested OS $PRETTY_NAME; continuing" >&2 ;;
|
||||
esac
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"""kernelwatch: fleet kernel and reboot status dashboard."""
|
||||
|
||||
__version__ = "0.3.0"
|
||||
__version__ = "0.3.1"
|
||||
|
||||
# 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.
|
||||
|
||||
@@ -84,6 +84,19 @@ def utc(ts: float | None) -> str:
|
||||
return time.strftime("%Y-%m-%d %H:%M:%S UTC", time.gmtime(ts)) if ts else ""
|
||||
|
||||
|
||||
def phased_summary(report: dict[str, Any]) -> tuple[str, str]:
|
||||
"""(short cell text, full description) for updates deferred by Ubuntu's phasing."""
|
||||
if report.get("os_id") not in (None, "ubuntu"):
|
||||
return "–", "this distribution doesn't phase updates"
|
||||
pkgs = report.get("phased_packages")
|
||||
if pkgs is None:
|
||||
return "?", "unknown: agent too old to report phased updates"
|
||||
if not pkgs:
|
||||
return "0", "none deferred"
|
||||
return str(len(pkgs)), ("held back by Ubuntu's phased rollout, not offered to this host "
|
||||
"yet (never security updates): " + ", ".join(pkgs))
|
||||
|
||||
|
||||
def services_summary(report: dict[str, Any]) -> tuple[str, str]:
|
||||
"""(short cell text, full description) for services needing a restart."""
|
||||
services = report.get("services_need_restart")
|
||||
@@ -407,7 +420,7 @@ class Handler(BaseHTTPRequestHandler):
|
||||
if not hosts else
|
||||
'<div class="table-wrap"><table><thead><tr>'
|
||||
"<th>Status</th><th>Host</th><th>OS</th><th>Running kernel</th>"
|
||||
"<th>Newest installed</th><th>Updates</th><th>Services</th><th>Uptime</th><th>Last seen</th>"
|
||||
"<th>Newest installed</th><th>Updates</th><th>Phased</th><th>Services</th><th>Uptime</th><th>Last seen</th>"
|
||||
"<th>Details</th></tr></thead><tbody>" + "".join(rows) + "</tbody></table></div>"
|
||||
)
|
||||
body = f'<main><div class="summary">{summary}</div>{table}</main>'
|
||||
@@ -420,13 +433,8 @@ class Handler(BaseHTTPRequestHandler):
|
||||
name = h["host"]
|
||||
sec = r.get("security_count")
|
||||
total = r.get("upgradable_count")
|
||||
phased = len(r.get("phased_packages") or [])
|
||||
updates = "–" if total is None else f"{total}" + (f" ({sec} sec)" if sec else "")
|
||||
updates_title = ""
|
||||
if phased:
|
||||
updates += f" +{phased} phased"
|
||||
updates_title = (f"{phased} more held back by Ubuntu's phased rollout: not offered to "
|
||||
"this host yet, never security updates")
|
||||
phased = phased_summary(r)
|
||||
services = services_summary(r)
|
||||
return (
|
||||
"<tr>"
|
||||
@@ -435,7 +443,8 @@ class Handler(BaseHTTPRequestHandler):
|
||||
f"<td>{e(r.get('os_pretty_name') or '–')}</td>"
|
||||
f"<td><code>{e(r.get('kernel_running') or '–')}</code></td>"
|
||||
f"<td><code>{e(r.get('kernel_newest_installed') or '–')}</code></td>"
|
||||
f'<td title="{e(updates_title)}">{e(updates)}</td>'
|
||||
f"<td>{e(updates)}</td>"
|
||||
f'<td title="{e(phased[1])}">{e(phased[0])}</td>'
|
||||
f'<td title="{e(services[1])}">{e(services[0])}</td>'
|
||||
f"<td>{e(duration(r.get('uptime_seconds')))}</td>"
|
||||
f'<td title="{e(utc(h["received_at"]))}">{e(ago(h["received_at"], now))}</td>'
|
||||
|
||||
+13
-2
@@ -91,6 +91,14 @@ class IngestTest(ServerCase):
|
||||
self.assertEqual(status, 413)
|
||||
|
||||
|
||||
class PhasedSummaryTest(unittest.TestCase):
|
||||
def test_cells(self):
|
||||
self.assertEqual(web.phased_summary({"os_id": "debian", "phased_packages": []})[0], "–")
|
||||
self.assertEqual(web.phased_summary({"os_id": "ubuntu"})[0], "?")
|
||||
self.assertEqual(web.phased_summary({"os_id": "ubuntu", "phased_packages": []})[0], "0")
|
||||
self.assertEqual(web.phased_summary({"os_id": "ubuntu", "phased_packages": ["a", "b"]})[0], "2")
|
||||
|
||||
|
||||
class DashboardTest(ServerCase):
|
||||
def test_requires_login(self):
|
||||
for path in ("/", "/host/web01"):
|
||||
@@ -124,7 +132,7 @@ class DashboardTest(ServerCase):
|
||||
self.add_host("db01") # never reports
|
||||
self.post_report(token, {"kernel_running": "6.8.0-85-generic",
|
||||
"kernel_newest_installed": "6.8.0-87-generic",
|
||||
"os_pretty_name": "Ubuntu 24.04.3 LTS <b>",
|
||||
"os_pretty_name": "Ubuntu 24.04.3 LTS <b>", "os_id": "ubuntu",
|
||||
"apt_lists_age_seconds": 60,
|
||||
"agent_version": "0.1.0",
|
||||
"services_need_restart": ["nginx.service"],
|
||||
@@ -145,7 +153,10 @@ class DashboardTest(ServerCase):
|
||||
self.assertIn("never reported", body)
|
||||
self.assertIn("1 service needs restart: nginx", body)
|
||||
self.assertIn("agent 0.1.0 is older", body)
|
||||
self.assertIn("2 (1 sec) +3 phased", body)
|
||||
self.assertIn("<th>Phased</th>", body)
|
||||
self.assertIn("<td>2 (1 sec)</td>", body)
|
||||
self.assertIn('held back by Ubuntu's phased rollout, not offered to this host yet '
|
||||
'(never security updates): systemd, udev, libudev1">3</td>', body)
|
||||
web01_reasons = body[body.rindex('<td class="reasons">'):].split("</td>")[0] # last row
|
||||
self.assertIn("security update", web01_reasons)
|
||||
self.assertNotIn("phas", web01_reasons, "phasing is never a status reason")
|
||||
|
||||
Reference in new issue
Block a user