hive-c0re: graceful agent stop — quiesce harness, flush state, then stop
This commit is contained in:
parent
bf65345b83
commit
03ea5d601b
8 changed files with 202 additions and 2 deletions
|
|
@ -185,6 +185,13 @@ pub(crate) async fn dispatch_shared(
|
|||
}
|
||||
hive_sh4re::Request::AckTurn => handle_ack_turn(coord, agent),
|
||||
hive_sh4re::Request::RequeueInflight => handle_requeue_inflight(coord, agent),
|
||||
hive_sh4re::Request::GracefulStopComplete => {
|
||||
// Harness drained + is exiting: clear the fence so the
|
||||
// `GracefulStop` orchestration (which polls this flag) proceeds
|
||||
// to stop the container without waiting out its timeout.
|
||||
coord.clear_graceful_stop(agent);
|
||||
hive_sh4re::Response::Ok
|
||||
}
|
||||
hive_sh4re::Request::GetHostJournal {
|
||||
unit,
|
||||
container,
|
||||
|
|
@ -221,6 +228,15 @@ async fn handle_recv(
|
|||
wait_seconds: Option<u64>,
|
||||
max: Option<u32>,
|
||||
) -> hive_sh4re::Response {
|
||||
// Graceful-stop fence: while a graceful stop is pending for this agent,
|
||||
// return `GracefulStop` instead of polling the broker. The harness runs
|
||||
// one stop-checkpoint turn then exits; new sends keep queueing in the
|
||||
// broker for the agent's next start. Checked before the (blocking) poll
|
||||
// so a flag set between polls is seen on the next Recv — the orchestration
|
||||
// also fires a transient wake to break an in-flight long-poll.
|
||||
if coord.is_graceful_stop_pending(agent) {
|
||||
return hive_sh4re::Response::GracefulStop;
|
||||
}
|
||||
let cap = max.unwrap_or(1).min(RECV_BATCH_MAX) as usize;
|
||||
match coord
|
||||
.broker
|
||||
|
|
|
|||
Loading…
Reference in a new issue