hivectl: collapse infra allowlist + restart/control ops onto SIBLING_CONTAINERS
Per review: RESTARTABLE_INFRA_CONTAINERS and the new CONTROLLABLE_INFRA_CONTAINERS
were near-identical subsets of SIBLING_CONTAINERS. Drop both and validate infra
lifecycle ops against SIBLING_CONTAINERS directly (all four infra containers;
hive-c0re is never in it, so it can't stop itself). This also makes hive-matrix
restartable, including via an infra_admin agent's restart tool.
Collapse the two priv ops too: RestartInfraContainer is gone; ControlInfraContainer
{ action } is the single op (restart = action: Restart). priv_client's
restart_infra_container is now a thin wrapper over control_infra_container.
This commit is contained in:
parent
c673dce73d
commit
0df9e40940
4 changed files with 46 additions and 109 deletions
|
|
@ -518,10 +518,10 @@ async fn handle_start_child(coord: &Arc<Coordinator>, agent: &str, name: &str) -
|
|||
async fn handle_restart_child(coord: &Arc<Coordinator>, agent: &str, name: &str) -> AgentResponse {
|
||||
// Infra-container restart: an agent holding the `infra_admin`
|
||||
// capability can restart a hive infrastructure container (hive-ci /
|
||||
// hive-gateway / hive-forge) by passing its name to the same restart
|
||||
// tool. These names are never agent children, so this branch is
|
||||
// disjoint from the child-restart path below.
|
||||
if hive_sh4re::priv_proto::RESTARTABLE_INFRA_CONTAINERS.contains(&name) {
|
||||
// hive-gateway / hive-forge / hive-matrix) by passing its name to the
|
||||
// same restart tool. These names are never agent children, so this
|
||||
// branch is disjoint from the child-restart path below.
|
||||
if hive_sh4re::priv_proto::SIBLING_CONTAINERS.contains(&name) {
|
||||
return handle_restart_infra(coord, agent, name).await;
|
||||
}
|
||||
if let Some(err) = require_child(agent, name, "restart") {
|
||||
|
|
@ -541,7 +541,7 @@ async fn handle_restart_child(coord: &Arc<Coordinator>, agent: &str, name: &str)
|
|||
|
||||
/// Restart a hive infrastructure container on behalf of an agent that
|
||||
/// holds the `infra_admin` capability. The container name is already
|
||||
/// known to be in `RESTARTABLE_INFRA_CONTAINERS`; this gates on the
|
||||
/// known to be in `SIBLING_CONTAINERS`; this gates on the
|
||||
/// capability and routes the systemctl restart through hive-priv (which
|
||||
/// re-validates the name root-side). Direct, not approval-gated.
|
||||
async fn handle_restart_infra(
|
||||
|
|
|
|||
|
|
@ -283,24 +283,20 @@ pub async fn restart_matrix_daemon(agent_name: &str) -> Result<()> {
|
|||
.await?)
|
||||
}
|
||||
|
||||
/// Restart a hive infrastructure container (hive-ci / hive-gateway /
|
||||
/// hive-forge) on the host via `systemctl restart
|
||||
/// container@<container>.service`. hive-priv re-validates `container`
|
||||
/// against its root-side allowlist; callers must already have checked
|
||||
/// the requesting agent holds the `infra_admin` capability.
|
||||
/// Restart a hive infrastructure container on the host (thin wrapper over
|
||||
/// [`control_infra_container`] with `action = Restart`). hive-priv
|
||||
/// re-validates `container` against its root-side allowlist; callers must
|
||||
/// already have checked the requesting agent holds the `infra_admin`
|
||||
/// capability.
|
||||
pub async fn restart_infra_container(container: &str) -> Result<()> {
|
||||
ok(call(&PrivRequest::RestartInfraContainer {
|
||||
container: container.to_owned(),
|
||||
})
|
||||
.await?)
|
||||
control_infra_container(container, InfraAction::Restart).await
|
||||
}
|
||||
|
||||
/// Start / stop / restart a hive infrastructure container (`hive-ci`,
|
||||
/// `hive-gateway`, `hive-forge`, `hive-matrix`) on the host via `systemctl
|
||||
/// <action> container@<container>.service`. hive-priv re-validates
|
||||
/// `container` against its root-side allowlist
|
||||
/// (`CONTROLLABLE_INFRA_CONTAINERS`). Used by the hive-wide `hivectl stop` /
|
||||
/// `hivectl start` flow.
|
||||
/// `container` against its root-side allowlist (`SIBLING_CONTAINERS`). Used
|
||||
/// by the hive-wide `hivectl stop` / `hivectl start` flow.
|
||||
pub async fn control_infra_container(container: &str, action: InfraAction) -> Result<()> {
|
||||
ok(call(&PrivRequest::ControlInfraContainer {
|
||||
container: container.to_owned(),
|
||||
|
|
|
|||
Loading…
Reference in a new issue