Treat Ubuntu Livepatch as cover for pending kernel reboots #14

Merged
patrick merged 2 commits from feat/livepatch into main 2026-10-30 01:45:30 +00:00
Owner

Summary

Hosts with Ubuntu Livepatch were flagged reboot permanently once a newer
kernel was installed, even though the running kernel stays patched. The agent
now collects Livepatch status and the server uses it.

Server

  • New livepatch_* report fields (state, check state, supported, end-of-support
    date, fix count).
  • If Livepatch is healthy (applied/nothing-to-apply, checked, supported)
    and the kernel's UpgradeRequiredDate is more than 14 days away, a pending
    kernel reboot, or a /run/reboot-required caused only by linux-* packages,
    is shown as a note (with the deadline) instead of reboot.
  • Other reboot reasons (libc, systemd) still count.
  • Unhealthy, unsupported or unrecognised Livepatch state gives no cover and is
    noted. No new status level, since the full state list is unknown.
  • Host page shows a Livepatch line.

Agent (0.4.0)

  • kernelwatch-livepatch.service runs canonical-livepatch status as root, no
    network, read-only filesystem, and a small python3 helper writes the running
    kernel's fields to /run/kernelwatch/livepatch. Skipped when the snap isn't
    installed. The unprivileged agent unit reads the file like needrestart's and
    never runs the snap itself.
  • NoNewPrivileges=yes can't be used: snap-confine fails with "cannot change
    profile for the next exec call" (tested on Ubuntu 22.04). The sandbox matches
    the combination that worked: PrivateNetwork, ProtectSystem=strict,
    PrivateTmp, ProtectHome=read-only. Documented in the README.

Rollout

Deploy the server first (an old server ignores the new fields). Hosts show the
"agent older than 0.4.0" note until redeployed with agent/deploy.sh.

Testing

make test: 136 tests pass. The helper is tested against real
canonical-livepatch status --format json output from Ubuntu 22.04 (applied)
and 24.04 (nothing-to-apply) hosts, including malformed input and line
injection. Status tests cover cover/no cover, the 14-day boundary, unhealthy
states, and kernel-only vs other reboot-required packages. A test checks every
agent field is accepted by the server.

Not yet run on a real host: the systemd unit itself (verify with
systemctl start kernelwatch-livepatch on a Pro host). make lint couldn't run
locally; CI covers it.

🤖 Generated with Claude Code

## Summary Hosts with Ubuntu Livepatch were flagged `reboot` permanently once a newer kernel was installed, even though the running kernel stays patched. The agent now collects Livepatch status and the server uses it. **Server** - New `livepatch_*` report fields (state, check state, supported, end-of-support date, fix count). - If Livepatch is healthy (`applied`/`nothing-to-apply`, `checked`, `supported`) and the kernel's `UpgradeRequiredDate` is more than 14 days away, a pending kernel reboot, or a `/run/reboot-required` caused only by `linux-*` packages, is shown as a note (with the deadline) instead of `reboot`. - Other reboot reasons (libc, systemd) still count. - Unhealthy, unsupported or unrecognised Livepatch state gives no cover and is noted. No new status level, since the full state list is unknown. - Host page shows a Livepatch line. **Agent (0.4.0)** - `kernelwatch-livepatch.service` runs `canonical-livepatch status` as root, no network, read-only filesystem, and a small python3 helper writes the running kernel's fields to `/run/kernelwatch/livepatch`. Skipped when the snap isn't installed. The unprivileged agent unit reads the file like needrestart's and never runs the snap itself. - `NoNewPrivileges=yes` can't be used: snap-confine fails with "cannot change profile for the next exec call" (tested on Ubuntu 22.04). The sandbox matches the combination that worked: PrivateNetwork, ProtectSystem=strict, PrivateTmp, ProtectHome=read-only. Documented in the README. ## Rollout Deploy the server first (an old server ignores the new fields). Hosts show the "agent older than 0.4.0" note until redeployed with `agent/deploy.sh`. ## Testing `make test`: 136 tests pass. The helper is tested against real `canonical-livepatch status --format json` output from Ubuntu 22.04 (applied) and 24.04 (nothing-to-apply) hosts, including malformed input and line injection. Status tests cover cover/no cover, the 14-day boundary, unhealthy states, and kernel-only vs other reboot-required packages. A test checks every agent field is accepted by the server. Not yet run on a real host: the systemd unit itself (verify with `systemctl start kernelwatch-livepatch` on a Pro host). `make lint` couldn't run locally; CI covers it. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
patrick added 2 commits 2026-10-30 01:39:39 +00:00
New livepatch_* report fields. When Livepatch is healthy (applied or
nothing-to-apply, checked, supported) and the kernel's support end date is
more than 14 days away, a pending kernel reboot, or a reboot-required file
caused only by linux-* packages, becomes a note instead of the reboot status.
Anything else about Livepatch gives no cover and is noted.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Collect Ubuntu Livepatch status in the agent
CI / tests (Python 3.10) (pull_request) Successful in 22s
CI / tests (Python 3.11) (pull_request) Successful in 22s
CI / tests (Python 3.12) (pull_request) Successful in 21s
CI / tests (Python 3.13) (pull_request) Successful in 21s
CI / lint (pull_request) Successful in 2s
b59336d7e2
kernelwatch-livepatch.service runs canonical-livepatch as root with no
network and a read-only filesystem, and a small python3 helper keeps the
running kernel's state, check state, support, end-of-support date and fix
count in /run/kernelwatch/livepatch. The agent (0.4.0) reads that file the
way it reads needrestart's and never runs the snap itself.

NoNewPrivileges=yes can't be used: snap-confine fails under it.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
patrick merged commit 3e62d086d1 into main 2026-10-30 01:45:30 +00:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: patrick/kernel-automation#14