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:
@@ -89,21 +89,15 @@ pub fn run(cfg: Config) -> anyhow::Result<()> {
|
|||||||
let events_state = state.clone();
|
let events_state = state.clone();
|
||||||
thread::spawn(move || {
|
thread::spawn(move || {
|
||||||
loop {
|
loop {
|
||||||
match docker_events_loop(&events_cfg, &events_state) {
|
let reason = match docker_events_loop(&events_cfg, &events_state) {
|
||||||
Ok(()) => {
|
Ok(()) => "docker events stream ended, restarting".to_string(),
|
||||||
set_err(
|
Err(e) => format!("docker events loop crashed: {e}"),
|
||||||
&events_state,
|
};
|
||||||
"docker_events",
|
// The reconnect writes its recovery, so the failure has to be written too. The
|
||||||
"docker events stream ended, restarting".to_string(),
|
// 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()) {
|
||||||
Err(e) => {
|
append_event(&format!("docker_events=error error=\"{reason}\""));
|
||||||
set_err(
|
|
||||||
&events_state,
|
|
||||||
"docker_events",
|
|
||||||
format!("docker events loop crashed: {e}"),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
thread::sleep(Duration::from_secs(10));
|
thread::sleep(Duration::from_secs(10));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user