Watch
0
0
Fork
You've already forked hyperhive
0

swarm-controller: the forge webhook takes two narrow sub-states

This commit is contained in:
atlas 2026-11-30 03:46:25 +01:00
commit 98341e24a6

View file

@ -6,8 +6,7 @@ use std::sync::{Arc, Mutex};
use anyhow::Result;
use swarm_authelia_bridge_sock::BridgeResponse;
use crate::routes::AppState;
use crate::routes::agents::{claiming_hives, read_declarations};
use crate::routes::agents::{claiming_hives, read_declarations_of};
use crate::startup::PUBLIC_URL_ENV;
use crate::{
agent_identity, agent_renewal, auth, builder, config_pr, forge, matrix_account, meta_build,
@ -1295,11 +1294,13 @@ pub(crate) fn spawn_jobq_worker(
/// Queue a build check of a config PR's new head. Every head is built, on
/// whichever hive the agent runs: the check builds on the builder's own
/// agent base.
pub(crate) fn queue_config_build(state: &AppState, changed: config_pr::ChangedConfigPr) {
pub(crate) fn queue_config_build(
jobq: &Mutex<hive_jobq::scheduler::Scheduler<SwarmNodeKind, SwarmResourceKind>>,
changed: config_pr::ChangedConfigPr,
) {
let (agent, rev, pr) = (changed.agent.clone(), changed.rev.clone(), changed.pr);
let queued = queue_build(
&mut state
.jobq
&mut jobq
.lock()
.unwrap_or_else(std::sync::PoisonError::into_inner),
changed,
@ -1354,11 +1355,13 @@ pub(crate) fn queue_build(
/// records an agent's hive (see `forge::initial_agent_nix`). Zero claimants or
/// several deploy nothing: there is no hive to send it to, or no telling which.
pub(crate) async fn queue_merged_config_deploy(
state: &AppState,
wanted: Option<&crate::wanted::WantedWriter>,
hives: &[crate::routes::hives::HiveEntry],
jobq: &Mutex<hive_jobq::scheduler::Scheduler<SwarmNodeKind, SwarmResourceKind>>,
merged: config_pr::MergedConfigPr,
) {
let config_pr::MergedConfigPr { agent, rev, pr } = merged;
let declared = match read_declarations(state, state.hives.iter()).await {
let declared = match read_declarations_of(wanted, hives.iter()).await {
Ok(declared) => declared,
Err((hive, e)) => {
tracing::warn!(
@ -1376,7 +1379,7 @@ pub(crate) async fn queue_merged_config_deploy(
);
return;
};
insert_merged_deploy(&state.jobq, hive, &agent, &rev, Some(pr));
insert_merged_deploy(jobq, hive, &agent, &rev, Some(pr));
}
/// Insert the [`merged_deploy_job`] of `agent`'s config at `rev` on `hive`.