Skip to content
Open
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
2 changes: 1 addition & 1 deletion apps/web/app/executions/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const WORKER_TERMINATION_CODES = ["worker_oom", "worker_evicted", "worker_exited
const PLATFORM_ERROR_TEXT = new Map<string, string>([
[
"worker_did_not_start",
"A worker took this run but never started it, so ORBIT ended it. This usually means the worker could not read the run, for example because it is older than the platform. Its logs in Workers say more.",
"A worker took this run but never started it, so ORBIT ended it. This usually means the worker could not read the run, for example because it is older than the platform, or that its container never started, for example because its image could not be pulled. Nothing ran, so the run can be retried. Its logs and launches in Workers say more.",
],
[
"worker_oom",
Expand Down
8 changes: 8 additions & 0 deletions changelog.d/399.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
- A launched worker whose container never ran (image pull or container config errors such as
`ImagePullBackOff`, `ErrImagePull` or `CreateContainerConfigError` with no earlier
termination) now ends as `worker_did_not_start`: only runs still `dispatched` to it fail,
marked retryable, and team queue items keep their retry. Previously these ended as
`worker_exited` with no retry although nothing ran. A Deployment whose evicted pod is still
listed next to a live replacement now follows the replacement instead of failing the
launch, and the OOM fallback for older launchers no longer matches words such as "room"
(#399).
8 changes: 5 additions & 3 deletions crates/orbit-api/src/background.rs
Original file line number Diff line number Diff line change
Expand Up @@ -876,10 +876,12 @@ pub(crate) async fn report_ended_execution(
// A worker that vanished (or stopped reporting a still-live harness) may have caused
// side effects, so its team run must not be auto-retried. The same holds for a worker
// terminated by the runtime (OOM, eviction, exit or node loss). Other endings keep the
// normal team poller behaviour, including queue retries for runs that never started.
// normal team poller behaviour, including queue retries for runs that never started
// (`worker_did_not_start`, from the reaper or from a container that never started).
let code = data.get("code").and_then(serde_json::Value::as_str);
let worker_terminated =
code.is_some_and(|code| orbit_contracts::WorkerTerminationReason::parse(code).is_some());
let worker_terminated = code
.and_then(orbit_contracts::WorkerTerminationReason::parse)
.is_some_and(orbit_contracts::WorkerTerminationReason::ends_without_retry);
if worker_terminated || matches!(code, Some("harness_unresponsive")) {
if let Err(error) =
crate::handlers::teams::fail_team_run_for_execution(state, execution).await
Expand Down
46 changes: 39 additions & 7 deletions crates/orbit-api/src/handlers/worker_launches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,7 @@ fn launch_termination(
if let Some(termination) = status.termination.clone() {
return Some(termination);
}
let oom = status
.error
.as_deref()
.is_some_and(|error| error.to_lowercase().contains("oom"));
let oom = status.error.as_deref().is_some_and(mentions_oom);
if !oom {
return None;
}
Expand All @@ -194,9 +191,19 @@ fn launch_termination(
))
}

/// True when a launcher error names an OOM kill as a word ("OOM", "OOMKilled"), not as part
/// of another word such as "room" or "zoom".
fn mentions_oom(error: &str) -> bool {
error
.split(|c: char| !c.is_ascii_alphanumeric())
.any(|word| word.eq_ignore_ascii_case("oom") || word.eq_ignore_ascii_case("oomkilled"))
}

/// A worker terminated by the runtime (OOM, eviction, exit or node loss) cannot report its
/// own execution failure. Fail every in-flight execution on that worker with the structured
/// reason, terminate the team step/run/queue without auto-retry, and audit the cause.
/// reason, terminate the team step/run/queue without auto-retry, and audit the cause. A
/// container that never started (`worker_did_not_start`) only fails runs still `dispatched`
/// to it, marked retryable, so the team poller keeps its normal queue retry.
async fn fail_worker_executions(
state: &AppState,
launch: &WorkerLaunch,
Expand All @@ -216,6 +223,16 @@ async fn fail_worker_executions(
return;
}
};
// A container that never started ran nothing: only runs still waiting for it end, and
// they keep their retry. A run already running on this worker id is left to the
// liveness reaper, since some other container must have started it.
let never_started = !termination.reason.ends_without_retry();
let executions: Vec<_> = executions
.into_iter()
.filter(|execution| {
!never_started || execution.status == orbit_domain::ExecutionStatus::Dispatched.as_str()
})
.collect();
let message = launch
.error
.clone()
Expand All @@ -230,8 +247,9 @@ async fn fail_worker_executions(
object.insert("workerId".into(), serde_json::json!(worker_id));
object.insert("profileId".into(), serde_json::json!(launch.profile_id));
object.insert("launchId".into(), serde_json::json!(launch.id));
// Side effects may already have happened; an operator must decide to rerun.
object.insert("retryable".into(), serde_json::json!(false));
// Side effects may already have happened; an operator must decide to rerun. A
// container that never started ran nothing, so its runs may be retried.
object.insert("retryable".into(), serde_json::json!(never_started));
}
for execution in executions {
let finished = state
Expand Down Expand Up @@ -750,3 +768,17 @@ mod worker_id_tests {
assert!(launch_worker_id(a).len() <= 63);
}
}

#[cfg(test)]
mod tests {
use super::mentions_oom;

#[test]
fn oom_fallback_matches_whole_words_only() {
assert!(mentions_oom("worker container was OOMKilled"));
assert!(mentions_oom("killed: oom (memory limit 512Mi)"));
assert!(!mentions_oom("no room left on device"));
assert!(!mentions_oom("zoom service unavailable"));
assert!(!mentions_oom("ImagePullBackOff"));
}
}
28 changes: 28 additions & 0 deletions crates/orbit-contracts/src/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ pub enum WorkerTerminationReason {
WorkerExited,
/// The node/pod disappeared or the cause could not be determined.
WorkerLost,
/// The container never started (image pull or container config error with no earlier
/// termination). Nothing ran, so the work may be retried.
WorkerDidNotStart,
}

impl WorkerTerminationReason {
Expand All @@ -25,6 +28,7 @@ impl WorkerTerminationReason {
"worker_evicted",
"worker_exited",
"worker_lost",
"worker_did_not_start",
];

pub fn as_str(self) -> &'static str {
Expand All @@ -33,6 +37,7 @@ impl WorkerTerminationReason {
Self::WorkerEvicted => "worker_evicted",
Self::WorkerExited => "worker_exited",
Self::WorkerLost => "worker_lost",
Self::WorkerDidNotStart => "worker_did_not_start",
}
}

Expand All @@ -42,6 +47,7 @@ impl WorkerTerminationReason {
"worker_evicted" => Some(Self::WorkerEvicted),
"worker_exited" => Some(Self::WorkerExited),
"worker_lost" => Some(Self::WorkerLost),
"worker_did_not_start" => Some(Self::WorkerDidNotStart),
_ => None,
}
}
Expand All @@ -53,8 +59,15 @@ impl WorkerTerminationReason {
Self::WorkerEvicted => "worker.evicted",
Self::WorkerExited => "worker.exited",
Self::WorkerLost => "execution.worker_lost",
Self::WorkerDidNotStart => "worker.did_not_start",
}
}

/// Whether work on a worker that ended this way may have had side effects, so the team
/// run must end without an automatic retry. A container that never started ran nothing.
pub fn ends_without_retry(self) -> bool {
!matches!(self, Self::WorkerDidNotStart)
}
}

/// Structured, non-secret termination information reported by the launcher.
Expand Down Expand Up @@ -105,6 +118,9 @@ impl WorkerTermination {
WorkerTerminationReason::WorkerLost => {
format!("{identity} was lost; the run outcome is unknown")
}
WorkerTerminationReason::WorkerDidNotStart => {
format!("{identity} never started its container, so nothing ran")
}
};
if let Some(detail) = self.detail.as_deref().filter(|value| !value.is_empty()) {
message.push_str(&format!(" ({detail})"));
Expand All @@ -126,6 +142,18 @@ mod tests {
assert!(WorkerTerminationReason::parse("oom").is_none());
}

#[test]
fn only_a_worker_that_never_started_allows_a_retry() {
for code in WorkerTerminationReason::ALL {
let reason = WorkerTerminationReason::parse(code).unwrap();
assert_eq!(
reason.ends_without_retry(),
reason != WorkerTerminationReason::WorkerDidNotStart,
"{code}"
);
}
}

#[test]
fn termination_json_is_camel_case_and_has_no_env() {
let termination = WorkerTermination {
Expand Down
4 changes: 3 additions & 1 deletion docs/architecture/events.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ a launch comes back `failed` with a structured `termination` (see
on that worker becomes `failed` with `worker_oom`, `worker_evicted`, `worker_exited` or
`worker_lost`, carrying the pod/container name, restart count, exit code and termination
time. Each gets an `error` event, an `orbit.execution.updated` message and an audit entry;
the team step, run and queue item become terminal with no automatic rerun.
the team step, run and queue item become terminal with no automatic rerun. A container that
never started (`worker_did_not_start`) only fails the executions still `dispatched` to it,
marked retryable, and the team poller keeps its normal queue retry.

## Scheduling and dispatch

Expand Down
7 changes: 5 additions & 2 deletions docs/architecture/runtime-contract.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ cause instead. `GET /launches/{id}` returns a `termination` object

| Field | Meaning |
|---|---|
| `reason` | `worker_oom`, `worker_evicted`, `worker_exited` or `worker_lost` |
| `reason` | `worker_oom`, `worker_evicted`, `worker_exited`, `worker_lost` or `worker_did_not_start` |
| `workerName` | pod name (Kubernetes) or container name (Docker) |
| `restartCount` | container restart count, when the runtime reports it |
| `terminatedAt` | RFC 3339 finish time reported by the runtime |
Expand All @@ -140,7 +140,10 @@ flight on that worker (`dispatched`, `running`, `awaiting_approval`) with the re
`error.code`, appends an `error` execution event, writes an audit entry
(`worker.oom_killed`, `worker.evicted`, `worker.exited`, `execution.worker_lost`) and ends
the team step, run and queue item without an automatic rerun: side effects may already have
happened, so a person decides whether to run it again.
happened, so a person decides whether to run it again. `worker_did_not_start` (an image pull
or container config error before the container ever ran) is the exception: it fails only the
executions still `dispatched` to that worker, marked `retryable: true`, audits
`worker.did_not_start`, and leaves the team poller's normal queue retry in place.

## Inputs

Expand Down
11 changes: 8 additions & 3 deletions docs/development/kubernetes-launcher.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,9 @@ Status is mapped by pure functions in `services/launcher/src/mapping.rs` from
| Exit code 137 without `OOMKilled` | `failed` | SIGKILL, explicitly not OOM | `worker_exited` |
| Any other non-zero exit | `failed` | exit code + reason | `worker_exited` |
| Deployment pod running after an earlier OOM restart | `running` | hint: OOMKilled earlier, restart count | none (still live) |
| CrashLoopBackOff, ImagePullBackOff, ErrImagePull, InvalidImageName, CreateContainerConfigError, CreateContainerError, RunContainerError | `failed` | reason, restart count, last termination | from `lastState.terminated`, else `worker_exited` |
| CrashLoopBackOff, or any waiting error below after the container already ran | `failed` | reason, restart count, last termination | from `lastState.terminated`, else `worker_exited` |
| ImagePullBackOff, ErrImagePull, InvalidImageName, CreateContainerConfigError, CreateContainerError, RunContainerError with no `lastState` (the container never ran) | `failed` | reason, restart count, waiting message | `worker_did_not_start` |
| Deployment with a terminal pod (for example evicted, phase `Failed`) and a live replacement pod | from the replacement (`running` / `starting`) | none | none |
| ContainerCreating / pending / not ready | `starting` | none | none |
| Job `Complete` | `stopped` | none | none |
| Job `Failed` condition (e.g. DeadlineExceeded, BackoffLimitExceeded) | `failed` | condition reason + message, container cause | container cause, else `Evicted` → `worker_evicted`, `DeadlineExceeded`/`BackoffLimitExceeded` → `worker_exited`, otherwise `worker_lost` |
Expand All @@ -186,8 +188,11 @@ A `failed` mapping also carries a structured `termination` object
container name), `restartCount`, `terminatedAt`, `exitCode` and a short `detail` such as
`OOMKilled`. It never contains env, command lines or logs. The API turns it into the
execution error (`data.code` = the reason), an `error` execution event, an audit entry, and
a terminal team step/run/queue item with no automatic rerun. Older launchers that only send
a human-readable `error` containing "OOM" are still understood as `worker_oom`.
a terminal team step/run/queue item with no automatic rerun. The exception is
`worker_did_not_start`: nothing ran, so only runs still `dispatched` to that worker end, marked
retryable, and the team poller keeps its normal queue retry. Older launchers that only send
a human-readable `error` naming "OOM" or "OOMKilled" as a word are still understood as
`worker_oom` (text such as "room" does not match).

The API only refreshes launches that are `pending`, `starting` or `running`, so a terminal
status it has already stored (for example `failed`) is never overwritten by a later
Expand Down
4 changes: 3 additions & 1 deletion docs/guide/executions.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ ended is expired and cannot be decided (409).
- `worker_did_not_start` (a `failed` run): a worker took the run but never started it.
ORBIT ends it after 10 minutes without activity, or one minute after you cancel it. The
worker's logs on the Workers page usually say why, for example a worker older than the
platform.
platform. A launched worker whose container never started (its image could not be pulled,
or its container config is invalid) ends the runs waiting for it the same way straight
away. Nothing ran, so a team queue item is retried as usual.

When the runtime reports them, a run ended by `worker_oom`, `worker_evicted`, `worker_exited`
or `worker_lost` also shows the worker/pod name, exit code, restart count and termination
Expand Down
4 changes: 3 additions & 1 deletion docs/guide/worker-profiles.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ stopping profiles needs `settings:write`.
- Stop deletes the workload; logs are read by the `orbit.launch-id` label
- A worker stopped by the runtime is surfaced as a failed launch with a structured reason:
`worker_oom` (OOMKilled, with the memory limit), `worker_evicted` (node pressure or drain),
`worker_exited` (non-zero exit) or `worker_lost` (node/pod gone). Exit code 137 alone is
`worker_exited` (non-zero exit), `worker_lost` (node/pod gone) or `worker_did_not_start`
(image pull or container config error before the container ever ran; its waiting runs
keep their retry). Exit code 137 alone is
SIGKILL, not OOM. Every in-flight execution on that worker fails with the same reason,
pod name, restart count, exit code and termination time; team runs are not retried
automatically. The API polls live launches every 15 seconds, so this happens even when
Expand Down
Loading