fc-queue-runner: one-at-a-time jobset scheduling

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: Iebe127bfba39979649826dfd0d28f9db6a6a6964
This commit is contained in:
raf 2026-02-08 02:13:00 +03:00
commit b791ed75f3
Signed by: NotAShelf
GPG key ID: 29D95B64378DB4BF

View file

@ -1,6 +1,9 @@
use std::{sync::Arc, time::Duration};
use fc_common::{models::BuildStatus, repo};
use fc_common::{
models::{BuildStatus, JobsetState},
repo,
};
use sqlx::PgPool;
use crate::worker::WorkerPool;
@ -117,6 +120,54 @@ pub async fn run(
},
}
// One-at-a-time scheduling: check if jobset allows concurrent builds
// First, get the evaluation to find the jobset
let eval =
match repo::evaluations::get(&pool, build.evaluation_id).await {
Ok(eval) => eval,
Err(e) => {
tracing::error!(
build_id = %build.id,
evaluation_id = %build.evaluation_id,
"Failed to get evaluation for one-at-a-time check: {e}"
);
continue;
},
};
let jobset = match repo::jobsets::get(&pool, eval.jobset_id).await {
Ok(jobset) => jobset,
Err(e) => {
tracing::error!(
build_id = %build.id,
jobset_id = %eval.jobset_id,
"Failed to get jobset for one-at-a-time check: {e}"
);
continue;
},
};
if jobset.state == JobsetState::OneAtATime {
match repo::jobsets::has_running_builds(&pool, jobset.id).await {
Ok(true) => {
tracing::debug!(
build_id = %build.id,
jobset = %jobset.name,
"One-at-a-time: skipping, another build is running"
);
continue;
},
Ok(false) => {},
Err(e) => {
tracing::error!(
build_id = %build.id,
"Failed to check running builds: {e}"
);
continue;
},
}
}
worker_pool.dispatch(build);
}
},