Supervisor: keep the Collector's error with a FAILED config; read system logs; clearer status and uninstall

Merged
ST
1mo ago
+185-16

Fixes from the 2026-10-28 Fleet e2e rerun on Supervisor 0.7.0, run in fresh macOS 15 and Ubuntu 24.04 VMs.

What changes

A FAILED config says why (e2e findings 2, 23). A bad remote config (an OTLP receiver on port 99999) rolled back as designed. But nothing on the host or the server kept the Collector's error: supervisor.log had no error, agent.log was rewritten by the restored config's start, and the status said only "Config apply timeout exceeded The last working remote config runs in its place."

  • The installers now set upstream's agent.collector_crash_log_snippet_kib: 4.
  • reportApply (already fork code) adds the Collector's log tail to every FAILED status, not only to an exit during the apply. That covers a timeout too, which is what macOS reported for the same crash.
  • The tail is read before the restore. The tail and opampsupervisor status now show the error on the host, through supervisor-status.json.
  • The rollback sentence stays last, on a line of its own after the tail: Platform's Diagnostic::reported recognizes rolled_back by ends_with("The last working remote config runs in its place.").
  • A period is added only when something follows the first message, so no other status text changes.
  • Result: Config apply timeout exceeded.\nCollector log tail:\n…\nThe last working remote config runs in its place.

Linux hosts can read system logs (e2e finding 22, Bill's call). On Ubuntu, /var/log/syslog, auth.log and kern.log are syslog:adm 0640. The Collector runs as pydantic-opamp, so it read none of them while Fleet showed Healthy.

  • postinstall.sh now adds the user to adm and systemd-journal where those groups exist, once per host.
  • A marker, /etc/pydantic-opamp/log-groups, keeps an operator's later gpasswd -d across upgrades.
  • The README documents how to opt out, and that RHEL's /var/log/messages is root-only.

opampsupervisor status, as the installers print it (finding 14). It printed Collector unhealthy since … (0s ago): with an empty reason. Before the first remote config it now says the Collector is waiting for it; otherwise it prints "unhealthy since …" without the dangling colon.

pydantic-opamp-uninstall (findings 16, 21).

  • The default run printed only pkgutil's or dpkg's line. It now says what it removed and kept, and how to purge.
  • It says the server still lists the host until its credentials are revoked.
  • A macOS purge removes the empty /opt/pydantic-opamp/share and /opt/pydantic-opamp.

OpAMP spec vs our choices

  • Spec: RemoteConfigStatus.error_message is the field for "why FAILED". It now carries the log tail.
  • Our choices, where the spec is open: the 4 KiB size, adding the tail to every FAILED status, keeping the rollback sentence last, and the group memberships (packaging only, outside OpAMP).

Tests

  • go test ./supervisor/ passes, except Test_NewSupervisorFailedStorageCreation, which fails only because the sandbox runs as root and fails on main too.
  • New tests:
    • TestARollbackStatusCarriesTheLogTailFirst, which runs the agent loop and checks the exact rollback message.
    • TestSupervisor_reportApply/failed carries the log tail.
    • TestAnUnhealthyCollectorWithoutAReason.
  • TestARollbackReportsOnlyTheFailedConfig now checks for the separate sentence.
  • go test ./packaging/ passes. The uninstall test checks the summary and the macOS directory cleanup.
  • postinstall.sh is covered by the root-only install test (-tags=install); sh -n passes here.

These reach hosts in the next Supervisor release, then the logfire-cli pin. Platform keeps storing only the diagnostic code by design. The Platform PR points users to opampsupervisor status for the Collector's error.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Cjw6MgEB6R44zDsCtsTwH6