reconcile: start a stopped harness inside a running container
hive-priv gains AgentHarness { agent_name, action: probe | start }, which
runs systemctl -M h-<name> against the fixed unit hive-agent.service.
run_reconcile and the 1-min tick read the unit for a running wanted-up
agent and start it when it is inactive or failed. A hive-priv without the
op reads as unknown state and leaves reconcile container-only.
This commit is contained in:
parent
ca734f8ea0
commit
36515c289d
1 changed files with 517 additions and 32 deletions
|
|
@ -8,8 +8,9 @@
|
|||
|
||||
use anyhow::{Context as _, Result, bail};
|
||||
use hive_priv_sock::{
|
||||
BindMount, CredentialMount, HiveFacts, InfraAction, InfraContainer, MEASURE_AGENT_DISK_TIMEOUT,
|
||||
NetworkIsolation, PRIV_SOCK, PrivEvent, PrivRequest, PrivResponse, PrivStream,
|
||||
BindMount, CredentialMount, HarnessAction, HiveFacts, InfraAction, InfraContainer,
|
||||
MEASURE_AGENT_DISK_TIMEOUT, NetworkIsolation, PRIV_SOCK, PrivEvent, PrivRequest, PrivResponse,
|
||||
PrivStream,
|
||||
};
|
||||
use hive_types::NixBuilds;
|
||||
use std::path::Path;
|
||||
|
|
@ -108,6 +109,20 @@ pub async fn start_failure_log(name: &str, since_unix: u64) -> Result<String> {
|
|||
Ok(stdout)
|
||||
}
|
||||
|
||||
/// Read (`Probe`, the unit's `LoadState` and `ActiveState` as `key=value`
|
||||
/// lines) or queue a start of (`Start`) the harness unit inside `name`'s
|
||||
/// container. An older hive-priv answers an error (it does not know the op).
|
||||
pub async fn agent_harness(name: &str, action: HarnessAction) -> Result<String> {
|
||||
let (stdout, _) = check(
|
||||
call(&PrivRequest::AgentHarness {
|
||||
agent_name: name.to_owned(),
|
||||
action,
|
||||
})
|
||||
.await?,
|
||||
)?;
|
||||
Ok(stdout)
|
||||
}
|
||||
|
||||
pub async fn stop_container(name: &str) -> Result<()> {
|
||||
ok(call(&PrivRequest::StopContainer {
|
||||
name: name.to_owned(),
|
||||
|
|
|
|||
Loading…
Reference in a new issue