fc-common: format
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I946272ee6563f5bca0844c5a25ba08f66a6a6964
This commit is contained in:
parent
015360ffcf
commit
23a4a8e348
3 changed files with 25 additions and 33 deletions
|
|
@ -387,11 +387,7 @@ pub async fn list_pinned_ids(
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set the `keep` (GC pin) flag on a build.
|
/// Set the `keep` (GC pin) flag on a build.
|
||||||
pub async fn set_keep(
|
pub async fn set_keep(pool: &PgPool, id: Uuid, keep: bool) -> Result<Build> {
|
||||||
pool: &PgPool,
|
|
||||||
id: Uuid,
|
|
||||||
keep: bool,
|
|
||||||
) -> Result<Build> {
|
|
||||||
sqlx::query_as::<_, Build>(
|
sqlx::query_as::<_, Build>(
|
||||||
"UPDATE builds SET keep = $1 WHERE id = $2 RETURNING *",
|
"UPDATE builds SET keep = $1 WHERE id = $2 RETURNING *",
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -77,8 +77,8 @@ pub async fn find_for_system(
|
||||||
) -> Result<Vec<RemoteBuilder>> {
|
) -> Result<Vec<RemoteBuilder>> {
|
||||||
sqlx::query_as::<_, RemoteBuilder>(
|
sqlx::query_as::<_, RemoteBuilder>(
|
||||||
"SELECT * FROM remote_builders WHERE enabled = true AND $1 = ANY(systems) \
|
"SELECT * FROM remote_builders WHERE enabled = true AND $1 = ANY(systems) \
|
||||||
AND (disabled_until IS NULL OR disabled_until < NOW()) \
|
AND (disabled_until IS NULL OR disabled_until < NOW()) ORDER BY \
|
||||||
ORDER BY speed_factor DESC",
|
speed_factor DESC",
|
||||||
)
|
)
|
||||||
.bind(system)
|
.bind(system)
|
||||||
.fetch_all(pool)
|
.fetch_all(pool)
|
||||||
|
|
@ -92,13 +92,11 @@ pub async fn find_for_system(
|
||||||
/// Backoff formula (from Hydra): delta = 60 * 3^(min(failures, 4) - 1) seconds.
|
/// Backoff formula (from Hydra): delta = 60 * 3^(min(failures, 4) - 1) seconds.
|
||||||
pub async fn record_failure(pool: &PgPool, id: Uuid) -> Result<RemoteBuilder> {
|
pub async fn record_failure(pool: &PgPool, id: Uuid) -> Result<RemoteBuilder> {
|
||||||
sqlx::query_as::<_, RemoteBuilder>(
|
sqlx::query_as::<_, RemoteBuilder>(
|
||||||
"UPDATE remote_builders SET \
|
"UPDATE remote_builders SET consecutive_failures = \
|
||||||
consecutive_failures = LEAST(consecutive_failures + 1, 4), \
|
LEAST(consecutive_failures + 1, 4), last_failure = NOW(), disabled_until \
|
||||||
last_failure = NOW(), \
|
= NOW() + make_interval(secs => 60.0 * power(3, \
|
||||||
disabled_until = NOW() + make_interval(secs => \
|
LEAST(consecutive_failures + 1, 4) - 1) + (random() * 30)::int ) WHERE \
|
||||||
60.0 * power(3, LEAST(consecutive_failures + 1, 4) - 1) + (random() * 30)::int \
|
id = $1 RETURNING *",
|
||||||
) \
|
|
||||||
WHERE id = $1 RETURNING *",
|
|
||||||
)
|
)
|
||||||
.bind(id)
|
.bind(id)
|
||||||
.fetch_optional(pool)
|
.fetch_optional(pool)
|
||||||
|
|
@ -110,10 +108,8 @@ pub async fn record_failure(pool: &PgPool, id: Uuid) -> Result<RemoteBuilder> {
|
||||||
/// Resets consecutive_failures and clears disabled_until.
|
/// Resets consecutive_failures and clears disabled_until.
|
||||||
pub async fn record_success(pool: &PgPool, id: Uuid) -> Result<RemoteBuilder> {
|
pub async fn record_success(pool: &PgPool, id: Uuid) -> Result<RemoteBuilder> {
|
||||||
sqlx::query_as::<_, RemoteBuilder>(
|
sqlx::query_as::<_, RemoteBuilder>(
|
||||||
"UPDATE remote_builders SET \
|
"UPDATE remote_builders SET consecutive_failures = 0, disabled_until = \
|
||||||
consecutive_failures = 0, \
|
NULL WHERE id = $1 RETURNING *",
|
||||||
disabled_until = NULL \
|
|
||||||
WHERE id = $1 RETURNING *",
|
|
||||||
)
|
)
|
||||||
.bind(id)
|
.bind(id)
|
||||||
.fetch_optional(pool)
|
.fetch_optional(pool)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue