fc-common: add GC pinning and machine health infrastructure
Migration 017 adds `builds.keep`, `jobsets.keep_nr`, and health tracking columns to `remote_builders`. Repo layer implements `set_keep`, `list_pinned_ids`, `record_failure` with exponential backoff, `record_success`, and `find_for_system` filtering of disabled builders. GC root cleanup now skips pinned builds. Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: Ibba121de3dc42f71204e3a8f5776aa8b6a6a6964
This commit is contained in:
parent
25699e5e97
commit
5b472a2f57
16 changed files with 173 additions and 23 deletions
|
|
@ -374,6 +374,34 @@ pub async fn get_completed_by_drv_paths(
|
|||
)
|
||||
}
|
||||
|
||||
/// Return the set of build IDs that have `keep = true` (GC-pinned).
|
||||
pub async fn list_pinned_ids(
|
||||
pool: &PgPool,
|
||||
) -> Result<std::collections::HashSet<Uuid>> {
|
||||
let rows: Vec<(Uuid,)> =
|
||||
sqlx::query_as("SELECT id FROM builds WHERE keep = true")
|
||||
.fetch_all(pool)
|
||||
.await
|
||||
.map_err(CiError::Database)?;
|
||||
Ok(rows.into_iter().map(|(id,)| id).collect())
|
||||
}
|
||||
|
||||
/// Set the `keep` (GC pin) flag on a build.
|
||||
pub async fn set_keep(
|
||||
pool: &PgPool,
|
||||
id: Uuid,
|
||||
keep: bool,
|
||||
) -> Result<Build> {
|
||||
sqlx::query_as::<_, Build>(
|
||||
"UPDATE builds SET keep = $1 WHERE id = $2 RETURNING *",
|
||||
)
|
||||
.bind(keep)
|
||||
.bind(id)
|
||||
.fetch_optional(pool)
|
||||
.await?
|
||||
.ok_or_else(|| CiError::NotFound(format!("Build {id} not found")))
|
||||
}
|
||||
|
||||
/// Set the `builder_id` for a build.
|
||||
pub async fn set_builder(
|
||||
pool: &PgPool,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue