Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pkgs/fleet/crates/fleet-queue/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ pub fn run(args: &[String]) -> i32 {
"unblock" => cmd_unblock(rest),
"dep-recheck" => cmd_dep_recheck(rest),
"quarantine-recheck" => cmd_quarantine_recheck(rest),
"repair" => cmd_repair(rest),
"cancel" => cmd_cancel(rest),
"revive" => cmd_revive(rest),
"fail" => cmd_fail(rest),
Expand Down
20 changes: 20 additions & 0 deletions pkgs/fleet/crates/fleet-queue/src/client/commands_lifecycle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1332,6 +1332,26 @@ pub(super) fn cmd_quarantine_recheck(rest: &[String]) -> i32 {
print_json(&require_row(&resp, "quarantine_recheck"));
0
}
/// repair (#13191): repair a quarantined / malformed task
/// packet in place. The broker re-runs the packet validators,
/// applies the deterministic repairs whose correct value can be
/// re-derived (today: the dedupe stamp, re-performed live), and
/// restores the task to claimable state; unrepairable defects
/// fail with the defect list and change nothing. --dry-run
/// reports defects + planned repairs and writes nothing.
pub(super) fn cmd_repair(rest: &[String]) -> i32 {
let args = parse_verb_args("repair", rest, &["worker", "reason"], &["dry-run"]);
reject_extra_pos("repair", &args, 1);
let body = json!({
"task_id": args.pos_i64(0, "task_id"),
"worker": opt_worker(&args),
"reason": args.get("reason").unwrap_or_default(),
"dry_run": args.has("dry-run"),
});
let resp = unwrap_ok(call("/repair", &body));
print_json(&require_row(&resp, "repair_task"));
0
}

pub(super) fn cmd_cancel(rest: &[String]) -> i32 {
let args = parse_verb_args("cancel", rest, &["worker", "reason"], &[]);
Expand Down
4 changes: 4 additions & 0 deletions pkgs/fleet/crates/fleet-queue/src/client/support.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ Run `repo-queue <verb> --help` for flags:\n\
unblock <task-id> [--worker <id>] [--reason <text>] [--drop-dep <list>]\n\
dep-recheck [--task <id>] [--limit <n>]\n\
quarantine-recheck [--task <id>] [--limit <n>]\n\
repair <task-id> [--worker <id>] [--reason <text>] [--dry-run]\n\
cancel <task-id> [--worker <id>] --reason <text>\n\
revive <task-id> [--worker <id>] [--reason <text>] [--not-before <ts>]\n\
fail <task-id> [--worker <id>] --error <text> [--reason-class <c>] [--execution <id>]\n\
Expand Down Expand Up @@ -268,6 +269,9 @@ pub(crate) fn usage(verb: &str) -> &'static str {
"quarantine-recheck" => {
"usage: repo-queue quarantine-recheck [--task <id>] [--limit <n>]\n\nRechecks quarantined tasks."
}
"repair" => {
"usage: repo-queue repair <task-id> [--worker <id>] [--reason <text>] [--dry-run]\n\nRepairs a quarantined or malformed task packet in place: re-runs the packet validators and applies the deterministic repairs whose correct value can be re-derived (today the dedupe stamp, re-performed live — a live duplicate refuses). Unrepairable defects fail with the defect list and change nothing. --dry-run reports defects and planned repairs, writing nothing."
}
"cancel" => {
"usage: repo-queue cancel <task-id> [--worker <id>] --reason <text>\n\nCancels a task. Without --worker, the cancellation is recorded under the default worker fleet-monitor."
}
Expand Down
2 changes: 2 additions & 0 deletions pkgs/fleet/crates/fleet-queue/src/turso_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ mod core;
mod label_enrich;
mod lifecycle;
mod placement_sessions;
mod repair;
mod stacks_outbox;
mod staleness;
mod work_identity;
Expand All @@ -61,6 +62,7 @@ pub use core::*;
pub use label_enrich::*;
pub use lifecycle::*;
pub use placement_sessions::*;
pub use repair::*;
pub use stacks_outbox::*;
pub use staleness::*;
pub use work_identity::*;
Expand Down
18 changes: 18 additions & 0 deletions pkgs/fleet/crates/fleet-queue/src/turso_queue/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,24 @@ pub(crate) fn verb_unblock(t: &TursoBackend, req: &Value) -> Value {
if let Some(drops) = &drops {
return unblock_drop(t, task_id, &worker, &reason, &row, drops);
}
// #13191 audit: a claim-path-quarantined row whose packet
// still fails the claim guard cannot be unblocked — the
// override would report it queued and the next claim
// would re-quarantine it. Refuse, name the quarantine,
// and point at repair, which fixes the packet in place.
// (The drop-dep form above stays available: it edits the
// dep record and leaves the row blocked, so it never
// misreports the row's state.)
let recorded = row.get("last_error").and_then(|v| v.as_str()).unwrap_or("");
if recorded.starts_with("quarantined by claim path") {
if let Some(guard) = claim_guard_reason(&row) {
return Err(format!(
"unblock_task: task {task_id} is quarantined ({guard}); \
unblock cannot clear a packet defect — repair the \
packet first with `fleet queue repair {task_id}`"
));
}
}
let prev_deps = deps_of(&row);
t.exec(
"UPDATE tasks SET status = 'queued', blocked_deps = NULL, \
Expand Down
Loading