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
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:
1 parent
5a11d31e66
commit
bc46c55298
15 files changed
+348
-7
No files matched your search
@@ -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):
|
||||
|
||||
Reference in new issue
Block a user