Event ingestion and job history
Armada turns job lifecycle events into three related records: a queue and job-set event history, a scheduler read model, and a user-facing job history. Pulsar carries the common event stream. Separate consumers convert the same events for Redis, the scheduler database, and the Lookout query database.
Event history model
An Armada event sequence is the shared record of state changes for jobs in one queue and job set. It can describe submission, scheduling, execution, retry, cancellation, preemption, success, failure, validation, and diagnostic information for a job and its job runs.
Jobs and job runs have different lifecycles. A job is the user request and may have several job runs. A job run is one attempt to execute that request. This distinction lets the history show both the final job result and the attempts that led to it.
The event model also carries the identity and timing needed to join records across the system. Event-specific data can add run detail, resource use, failure classification, and the retry policy that affected the result. The page Protobuf APIs and events describes the shared event and API contracts.
- The queue and job-set name scope the event stream.
- The job ID identifies the user request.
- The run ID identifies one execution attempt.
- Event creation time gives the lifecycle order within the event data.
References: pkg/…/events.proto• L12-62 pkg/…/events.proto• L64-109 pkg/…/events.proto• L466-525
Event stream flow
Pulsar is the handoff point between components that produce lifecycle events and components that build durable views. Executors report run events, while Armada services report scheduler and job state events. Each history consumer uses its own subscription so it can process the same source independently.
This diagram shows how one Armada event stream feeds the durable views and read interfaces.
flowchart LR
P[Pulsar job-set event topic] --> E[Event store consumer]
P --> S[Scheduler consumer]
P --> L[Lookout consumer]
E --> R[Redis event streams]
S --> SD[Scheduler database]
L --> LD[Lookout PostgreSQL database]
R --> W[Job-set event API]
LD --> Q[Lookout query APIs and UI]
SD --> SC[Scheduler state and decisions]
The shared ingestion pipeline reads messages, decodes event sequences, groups work into batches, converts events into a sink-specific form, and acknowledges the source messages after the sink completes. This common flow keeps delivery work separate from the rules for each durable view.
Source event delivery
The job-set event topic is consumed from the earliest available subscription position. Batching improves write efficiency, but the batch keeps every source message ID so the consumer can acknowledge the complete input set after processing.
An invalid message cannot produce a useful event sequence. The pipeline records the decode error and keeps its message ID for acknowledgement handling. This means source delivery and event validity are separate concerns. The Platform contracts and clients page provides the wider view of the contracts that connect Armada services and clients.
References: internal/…/ingestion_pipeline.go• L21-63 internal/…/ingestion_pipeline.go• L135-213 internal/…/ingestion_pipeline.go• L215-243 internal/…/utils.go• L14-39
Sink-specific projections
Each consumer interprets the event model for a different purpose. The event store keeps a replayable stream. The scheduler consumer keeps the data needed for current scheduling and event ordering. The Lookout consumer turns lifecycle changes into searchable job and run records.
The projections are related but are not interchangeable. Redis preserves event-oriented history for a job set. Lookout stores the latest job and run facts for queries. The scheduler database stores the state and metadata needed by scheduling decisions.
References: internal/…/ingester.go• L104-139 internal/…/ingester.go• L63-86 internal/…/ingester.go• L51-85
Event store history
The event store provides chronological job-set history for clients that need to replay or watch events. The dedicated page Event store and ingestion describes its storage contract in more detail.
The event ingester removes queue and job-set identity from the stored event payload because the stream key carries that identity. It removes cancellation reasons, run start-up details, and debug-only fields. It also drops event types that do not serve Redis public history, including job-run success, validation, and termination-debug events. For job-run errors, it retains only the lifecycle error data used by Redis clients and removes debug text. Lookout reads the dropped data directly from Pulsar. The remaining sequence is compacted, limited to the configured size, and compressed before it is stored.
Redis assigns each stored entry a position. A retention policy expires each stream, so this history is durable for its configured lifetime rather than an unlimited archive.
When a client reads history, the event service reads Redis entries, restores the queue and job-set identity, decompresses the sequence, and converts internal events into public API messages. One internal event can produce more than one public message. Internal-only events are not returned when they have no public API form.
Replay and watch access
The event API supports two read modes. A normal request reads through the current end of a job-set stream. A watch request continues to wait for later entries. Clients use the returned external message ID as a cursor for later reads.
The cursor includes the Redis entry position and the index of the public message produced from that entry. This detail allows a client to resume inside a stored sequence without repeating already delivered public messages.
References: internal/…/conversions.go• L37-102 internal/…/conversions.go• L105-132 internal/…/conversions.go• L134-176 internal/…/eventstore.go• L46-78 internal/…/eventstore.go• L111-141 internal/…/event_repository.go• L69-113 internal/…/event.go• L85-151 internal/…/sequence.go• L10-19
Scheduler history
The scheduler ingester builds the scheduler database from the same job-set events. Its goal is not to expose a full event replay. It maintains the ordered job and run data that the scheduler needs to select work and apply later state changes safely.
A submission creates scheduler metadata and a compact scheduling view. Lease, assignment, running, success, failure, retry, validation, cancellation, reprioritisation, and preemption events then update that view. Control-plane events use a second input stream to update executor settings and apply queue, executor, or node actions.
The scheduler database applies related operations in a transaction. Job-set event writes use a shared database lock because the scheduler reads monotonically increasing row sequence values to find changes. This preserves a usable update order when more than one ingestion operation is active.
References: internal/…/ingester.go• L24-34 internal/…/ingester.go• L51-85 internal/…/instructions.go• L81-148 internal/…/instructions.go• L151-244 internal/…/schedulerdb.go• L55-97
User-facing job history
Lookout is the query-oriented view of job history. Its ingester consumes the common event stream and writes searchable job, job-run, job-specification, annotation, error, and run-detail data to PostgreSQL. The query service then presents that data to API clients and the Lookout UI.
The Lookout view keeps both summary and detail. A job record represents the request and its current state. Job-run records preserve each execution attempt with timestamps, placement data, result details, and failure information. Supplementary run data preserves startup details, while the run record also keeps the executor-reported pod name. The original job specification and selected annotations remain available for inspection.
History projection
Lookout converts each supported event into a small set of job or run changes. Submission creates the job and its specification. Lease creates a run. Later run events fill in pending, started, finished, error, exit, ingress, and preemption data. Terminal job events set the final job state.
Diagnostic termination events add debug text for a run without changing its state. The cancellation event owns the cancelled state, so the two updates can arrive in either order without changing the result. Run errors can also add failure text, debug text, exit data, failure category and subcategory, retry policy information, and terminal failure classification. Preemption and cancellation preserve the reason and the actor or related job context when that information exists.
The converter ignores events that do not change the Lookout view. It also protects the query model from stale transitions after a job reaches a terminal state. Repeated changes in one batch are combined before persistence, which keeps the final view consistent and reduces write work. The persistence layer creates jobs and their specifications before dependent updates, then stores job changes, runs, errors, and run details before applying run changes. It uses batch writes with a slower row-by-row fallback when needed.
Lookout run updates preserve fields that the event does not provide, while explicit empty or zero values replace stored values. A late job-state update remains filtered after the job reaches a terminal state, but a valid late run update can still add run detail.
References: internal/…/instructions.go• L69-145 internal/…/instructions.go• L147-213 internal/…/instructions.go• L267-353 internal/…/instructions.go• L436-478 internal/…/instructions.go• L481-587 internal/…/instructions.go• L590-605 internal/…/insertion.go• L38-100 internal/…/insertion.go• L1166-1414 internal/…/run_update_contract_test.go• L106-314
Run detail persistence
Lookout stores run detail across the main run record and a supplementary record keyed by run ID. The supplementary record stores startup information as JSON. The main run record stores the executor-reported pod name, so query results can relate a run to the pod that executed it. The submission event can also state whether pod names are scoped to runs, which helps clients interpret pod identity across retries.
Lookout also makes executor diagnostics available for a run. The debug endpoint returns the stored message unchanged and adds structured pod and node details when the message is valid JSON with the supported schema version, trigger, and pod data. This gives clients a raw diagnostic fallback while allowing the UI to present useful pod, container, node, and event information when it can be safely parsed.
References: pkg/…/events.proto• L129-171 internal/…/038_create_job_run_info.sql• L1-5 internal/…/039_add_job_run_pod_name.sql• L1-2 internal/…/application.go• L126-137 internal/…/debuginfo.go• L9-27 internal/…/swagger.yaml• L309-464 internal/…/swagger.yaml• L676-707
History retention
Lookout history has a bounded lifetime. The pruner selects only terminal jobs whose last transition is older than the configured job lifetime, then removes the job and its related specification, run, run-detail, and error records in batches. Active jobs remain available even when their last transition is old. In a hot-cold schema, the same rule applies to the terminated-job store. Deduplication records use a separate lifetime.
References: internal/…/pruner.go• L16-42 internal/…/pruner.go• L45-54 internal/…/pruner.go• L56-103 internal/…/pruner.go• L105-162 internal/…/pruner_test.go• L136-207
Query and detail access
Lookout query services use the stored view for filtered job lists, grouped job counts, job status, job and run details, job specifications, and error details. A job query can include its runs, and a run ID filter finds the owning job when any of that job's runs matches. Separate detail calls can fetch compressed specifications or error text when needed. The page Lookout query services covers these read paths and their client-facing contracts.
The Lookout jobs view turns these query capabilities into an interactive history table. Users can filter by job fields and annotations, group related jobs, sort and page through results, refresh active data, and open a job detail sidebar. They can select jobs or groups for control actions such as cancel, reprioritize, and preempt. The view keeps its table state in query parameters and can save named custom views, so a shared link or saved view can restore the same history slice. The page Lookout user interface describes this user-facing view.
The REST service exposes job queries and group queries. Armada's server-side Query API reads the same job and run view for programmatic status and detail calls.
The Lookout API also exposes a run-scoped diagnostic call. A client supplies a run ID and receives the exact stored debug message plus optional structured pod debug information. The structured form includes the capture trigger, pod state, container state, pod events, and node state when those fields pass the supported payload checks.
References: internal/…/getjobs.go• L18-20 internal/…/getjobs.go• L66-140 internal/…/querybuilder.go• L62-198 internal/…/querybuilder.go• L538-600 internal/…/tables.go• L91-166 internal/…/tables.go• L194-227 internal/…/groupjobs.go• L18-31 internal/…/doc.go• L1-14 internal/…/query_api.go• L58-143 internal/…/getjobspec.go• L17-60 internal/…/JobsTableContainer.tsx• L224-240 internal/…/JobsTableContainer.tsx• L270-369 internal/…/JobsTableActionBar.tsx• L145-239 internal/…/getjobs_test.go• L239-264 internal/…/application.go• L126-137 internal/…/debuginfo.go• L9-27 internal/…/swagger.yaml• L676-707
History consistency
The three views have different shapes and lifetimes, but they share event identity and lifecycle meaning. A job ID and run ID connect an event in Redis to the corresponding scheduler and Lookout records. Queue and job-set identity scope both the event stream and the scheduler operations.
The views can become temporarily different because they consume and persist independently. Redis can expire old streams while Lookout retains its current rows. Debug information can be available to Lookout without being present in Redis because the event store removes it from its stored payload. A public event can be absent even when the same internal event updated Lookout or the scheduler because public conversion filters internal-only event types. Engineers should therefore choose the view that matches the question:
| Need | Primary view | Result |
|---|---|---|
| Replay or watch lifecycle messages | Redis event stream | Ordered public event messages for one queue and job set |
| Make a scheduling decision | Scheduler database | Current scheduling state and run metadata |
| Search jobs or inspect a run | Lookout database | Filtered job history and detail fields |
| Find a job from any execution attempt | Lookout database | The job record linked to the matching run ID |
| Inspect startup or pod detail | Lookout database | Run detail associated with a run ID |
| Inspect executor diagnostics | Lookout API | Raw run debug text and optional structured pod and node details |
References: pkg/…/events.proto• L97-109 internal/…/conversions.go• L51-60 internal/…/conversions.go• L17-76 internal/…/model.go• L81-95 internal/…/querybuilder.go• L572-579 internal/…/query_api.go• L17-42
Change checklist
When these files or sections are changed, remember to consider these:
- Changes to an
EventSequenceevent type must be checked in the Redis public conversion, scheduler conversion, and Lookout conversion. An event may need different handling in each view. - Changes to event-store filtering must be checked against the data that Lookout reads directly from Pulsar and the data that Redis clients expect to replay. This includes success, validation, termination-debug, and selected error events.
- Changes to job or run identity fields must preserve joins between Redis cursors, scheduler rows, Lookout rows, and public API messages.
- Changes to event ordering or database sequence handling must be checked against scheduler incremental reads and event API cursor replay.
- Changes to event retention must be checked against the expected replay window and the difference between Redis history and PostgreSQL query rows.
- Changes to terminal-state handling must be checked against late events so a completed job does not return to an active state in Lookout or the scheduler.
- Changes to public event conversion must be checked for private fields and internal-only events that must not appear in user-facing history.
- Changes to the shared ingestion pipeline must preserve the contract that source messages are acknowledged only after sink processing and that shutdown leaves unfinished work for redelivery.
- Changes to Lookout persistence ordering must preserve job creation before dependent rows and must keep cancellation and preemption metadata available after terminal-state filtering.
- Changes to Lookout query fields, filter rules, grouping rules, or job state names must stay aligned with the jobs table columns, URL state, saved views, and server query contracts.
- Changes to Lookout run ID lookup must preserve the link from any
job_run.run_idto its parent job and must keep the exact-match contract exposed by the query model. - Changes to run-detail schema must keep startup information and pod names connected to the run ID, and must include the retention path that removes those records with their parent job.
- Changes to the run debug message schema or parser must keep the raw stored message available while preserving the supported structured diagnostic fields and schema-version checks.
- Changes to the run debug endpoint must keep its run ID lookup, generated API contract, and raw-versus-structured response behavior aligned.
- Changes to grouped selection or expanded-row paging must preserve the filter and exclusion meaning sent to bulk job actions.
- Changes to event failure fields, resource-use fields, or pod-name scope must be checked against every projection and the clients that use the resulting history.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A Pulsar payload cannot be decoded | No projection is built from that message. Its message ID still reaches acknowledgement handling. | The job-set unmarshaller records the decode error and retains the source ID. |
| A Redis stream expires | Clients cannot replay events older than the retention window. | The event store applies an explicit retention policy that defines the replay window. |
| Event-store conversion removes data needed by a Redis client | Redis history lacks that data even though the source event remains available to Lookout. | The Redis converter removes only data outside the event-store contract and keeps the queue and job-set identity in the stream key. |
| An internal event has no public API mapping | The event is absent from the event API even if it updates another durable view. | Public conversion has an explicit ignored-event set. |
| A database write fails during shutdown | Acknowledging the source too early can leave a missing or partial scheduler or Lookout view. | Sink cancellation returns an error so the shared pipeline leaves affected messages for redelivery. |
| A late state event arrives after a job is terminal | Lookout can show a zombie job that appears active again. | Lookout filters terminal-job updates and conflates updates before writing them. |
| A diagnostic termination event sets the run state | A later or earlier cancellation update can be hidden or overwritten in Lookout. | The diagnostic event writes debug text only. The cancellation event sets the run state. |
| Concurrent scheduler writes interleave row sequence values | Incremental scheduler reads can miss or misorder changes. | Job-set writes use a PostgreSQL advisory lock in the transaction. |
| A job or run ID is missing or changed in one projection | Queries cannot join the event, job, and run records. | The event model carries queue, job-set, job, and run identity as shared contract fields. |
| Run-detail rows are not included in job retention cleanup | Startup or pod detail can remain after the job history is removed, or the detail can become unavailable through its expected parent history. | The pruner deletes job_run_info rows with the selected jobs' runs and tests that run-detail IDs match the remaining runs. |
| A run ID filter is mapped to the job table as a direct column | A query can miss jobs whose matching run is not the latest run, or fail against a column that is not stored on the job table. | Lookout resolves the exact run ID through the run table and returns its parent job. |
| A stored run debug message is malformed or uses an unsupported schema | The structured diagnostic view is absent, although the original debug text remains available. | Lookout validates the JSON shape, required pod data, trigger, and supported schema version before creating structured debug information. |
| A dependent Lookout filter is restored without its prerequisite | The filter is dropped or cannot be applied through the table. | The jobs view prunes filters that lack a non-empty prerequisite and offers a scoped undo action. |
| A grouped selection is converted with the wrong exclusions | A bulk action can target jobs outside the selected group or omit selected jobs. | The table converts group selections into filters with child exclusions before sending the action request. |
Key files
| File | Why to read it |
|---|---|
| pkg/…/events.proto | Defines the shared job, job-run, and lifecycle event model. |
| internal/…/ingestion_pipeline.go | Shows the common delivery, batching, conversion, sink, and acknowledgement flow. |
| internal/…/ingester.go | Assembles the event-to-Redis history path. |
| internal/…/conversions.go | Defines which event data is kept for Redis history and how stored sequences are prepared. |
| internal/…/conversions_test.go | Guards Redis history filtering, field removal, and event-size accounting behavior. |
| internal/…/eventstore.go | Defines Redis stream persistence, retention, and write retry behavior. |
| internal/…/event.go | Defines replay and watch access to job-set event history. |
| internal/…/event_repository.go | Reads Redis history and creates public event messages and cursors. |
| internal/…/ingester.go | Assembles the scheduler database consumer and its control-plane input. |
| internal/…/instructions.go | Shows how lifecycle events become scheduler operations. |
| internal/…/schedulerdb.go | Defines transactional scheduler persistence and ordering protection. |
| internal/…/instructions.go | Shows how lifecycle events become job and run history updates. |
| internal/…/insertion.go | Defines Lookout persistence order, fallback writes, and terminal-state protection. |
| internal/…/run_update_contract_test.go | Defines the persistence contract for partial, empty, repeated, failed, cancelled, and late run updates. |
| internal/…/038_create_job_run_info.sql | Defines the supplementary store for run startup information. |
| internal/…/039_add_job_run_pod_name.sql | Adds the executor-reported pod name to run history. |
| internal/…/pruner.go | Defines terminal-job retention and cleanup of related history rows. |
| internal/…/pruner_test.go | Verifies retention boundaries and cleanup across job, run, detail, and error data. |
| internal/…/getjobs.go | Shows how stored job and run data becomes query results. |
| internal/…/querybuilder.go | Maps supported job and run filters, including lookup by any run ID, to query behavior. |
| internal/…/tables.go | Defines the fields, tables, filters, sort rules, and group rules available to Lookout queries. |
| internal/…/getjobs_test.go | Verifies that a run ID resolves to its parent job and that query results preserve job and run history. |
| internal/…/query_api.go | Shows programmatic access to job status, details, runs, specifications, and errors. |
| internal/…/application.go | Connects the run debug repository to the Lookout API and returns raw and structured diagnostic data. |
| internal/…/debuginfo.go | Defines which stored run debug messages become structured diagnostic data. |
| internal/…/swagger.yaml | Defines the run debug endpoint and the pod and node diagnostic response contract. |
| internal/…/JobsTableContainer.tsx | Coordinates query-backed table state, refresh, grouping, filtering, selection, and job detail access. |
| internal/…/jobsTableColumns.tsx | Defines the user-facing job fields, filters, groups, annotations, and displayed state. |
| internal/…/jobsTableUtils.ts | Defines how table filters and grouped selections become Lookout query and action filters. |
| internal/…/JobsTableActionBar.tsx | Connects history-table controls to refresh, saved views, grouping, and bulk job actions. |
| pkg/…/event.proto | Defines the public event messages and job-set event stream interface. |