Let an agent report a chosen hostname
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 22s
CI / tests (Python 3.13) (pull_request) Successful in 21s
CI / lint (pull_request) Successful in 3s
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 22s
CI / tests (Python 3.13) (pull_request) Successful in 21s
CI / lint (pull_request) Successful in 3s
REPORT_HOSTNAME in agent.conf replaces hostname -f in the report, for hosts registered under a label that differs from their real hostname (otherwise the dashboard notes a mismatch forever). install.sh --report-hostname NAME sets it, --default-report-hostname clears it, and re-running with --server (register, rotate) keeps it. Agent 0.4.1. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3e62d086d1
commit
10b1d6abb8
6 files changed
+57
-6
No files matched your search
@@ -139,6 +139,22 @@ class AgentReportTest(AgentCase):
|
||||
self.write_livepatch("LIVEPATCH-STATE: applied\nLIVEPATCH-FIXES: 2\n")
|
||||
self.assertEqual(sorted(set(self.report()) - set(FIELDS)), [])
|
||||
|
||||
def write_conf(self, text):
|
||||
with open(os.path.join(self.root, "etc/kernelwatch/agent.conf"), "w") as f:
|
||||
f.write(text)
|
||||
|
||||
def test_report_hostname_overrides_the_machines_own(self):
|
||||
self.write_conf("SERVER_URL=http://x\nREPORT_HOSTNAME=iris\n")
|
||||
self.assertEqual(self.report()["reported_hostname"], "iris")
|
||||
|
||||
def test_blank_report_hostname_uses_the_machines_own(self):
|
||||
self.write_conf("REPORT_HOSTNAME=\n")
|
||||
self.assertEqual(self.report()["reported_hostname"], "web01.example")
|
||||
|
||||
def test_report_hostname_is_json_escaped(self):
|
||||
self.write_conf('REPORT_HOSTNAME=a"b\\c\n')
|
||||
self.assertEqual(self.report()["reported_hostname"], 'a"b\\c')
|
||||
|
||||
def test_no_livepatch_file_reports_nulls(self):
|
||||
r = self.report()
|
||||
for key in ("state", "check_state", "supported", "upgrade_required", "fix_count"):
|
||||
|
||||
Reference in new issue
Block a user