fix(daemon): record the docker events failure, not only the recovery [P2]

The outer loop called set_err and dropped the result, so no docker_events=error line was
ever written while the reconnect did write docker_events=recovered. The events log could
therefore show a recovery from a failure it had never recorded, which contradicts its
documented contract of holding transitions in both directions. last_action.state was
correct throughout - this was the journal only.

Both branches now build the reason and share one report, matching the wording the periodic
reconcile already uses.
This commit is contained in:
2026-08-07 06:15:38 +05:00
parent 383e67605a
commit 3912b91bc4
+9 -15
View File
@@ -89,21 +89,15 @@ pub fn run(cfg: Config) -> anyhow::Result<()> {
let events_state = state.clone();
thread::spawn(move || {
loop {
match docker_events_loop(&events_cfg, &events_state) {
Ok(()) => {
set_err(
&events_state,
"docker_events",
"docker events stream ended, restarting".to_string(),
);
}
Err(e) => {
set_err(
&events_state,
"docker_events",
format!("docker events loop crashed: {e}"),
);
}
let reason = match docker_events_loop(&events_cfg, &events_state) {
Ok(()) => "docker events stream ended, restarting".to_string(),
Err(e) => format!("docker events loop crashed: {e}"),
};
// The reconnect writes its recovery, so the failure has to be written too. The
// journal is documented as holding transitions in both directions, and dropping
// this one left it showing a recovery from a failure it never recorded.
if set_err(&events_state, "docker_events", reason.clone()) {
append_event(&format!("docker_events=error error=\"{reason}\""));
}
thread::sleep(Duration::from_secs(10));
}