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
105 changes: 105 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions crates/ruscker-admin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ http-body-util = { workspace = true }
# the connector must be built with one explicitly.
hyper-rustls = "0.27"
rustls = { version = "0.23", default-features = false, features = ["ring", "std", "tls12", "logging"] }
# Cron parsing for scheduled jobs (#986) — verified on crates.io (3.0.1).
croner = "3"
futures-util = { workspace = true }
async-stream = { workspace = true }
lol_html = { workspace = true }
Expand Down
24 changes: 24 additions & 0 deletions crates/ruscker-admin/migrations-pg/0028_schedules.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
-- Postgres twin of migrations/0028 (#986 slice B).
CREATE TABLE schedules (
id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
spec_id TEXT NOT NULL,
cron TEXT NOT NULL,
cmd_json TEXT,
enabled BOOLEAN NOT NULL DEFAULT TRUE,
timeout_secs BIGINT,
last_run_at TIMESTAMPTZ,
created_at TIMESTAMPTZ NOT NULL,
updated_at TIMESTAMPTZ NOT NULL
);

CREATE TABLE schedule_runs (
id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
schedule_id BIGINT NOT NULL REFERENCES schedules(id) ON DELETE CASCADE,
started_at TIMESTAMPTZ NOT NULL,
finished_at TIMESTAMPTZ,
status TEXT NOT NULL,
exit_code BIGINT,
log_tail TEXT,
duration_ms BIGINT
);
CREATE INDEX idx_schedule_runs_schedule ON schedule_runs(schedule_id, started_at DESC);
30 changes: 30 additions & 0 deletions crates/ruscker-admin/migrations/0028_schedules.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
-- Scheduled jobs (#986 slice B): cron-triggered run-to-completion
-- executions of a spec's image (ETL, reports). `cmd_json` is an
-- optional argv override (JSON array) — NULL runs the spec's own
-- command. `last_run_at` is the scheduler's fire marker (set BEFORE
-- the job runs, so a crash mid-job never double-fires).
CREATE TABLE schedules (
id INTEGER PRIMARY KEY AUTOINCREMENT,
spec_id TEXT NOT NULL,
cron TEXT NOT NULL,
cmd_json TEXT,
enabled INTEGER NOT NULL DEFAULT 1,
timeout_secs INTEGER,
last_run_at TEXT,
created_at TEXT NOT NULL,
updated_at TEXT NOT NULL
);

-- Run history. `status`: 'ok' (exit 0) | 'failed' (non-zero exit) |
-- 'error' (could not run: pull/create/start/timeout).
CREATE TABLE schedule_runs (
id INTEGER PRIMARY KEY AUTOINCREMENT,
schedule_id INTEGER NOT NULL REFERENCES schedules(id) ON DELETE CASCADE,
started_at TEXT NOT NULL,
finished_at TEXT,
status TEXT NOT NULL,
exit_code INTEGER,
log_tail TEXT,
duration_ms INTEGER
);
CREATE INDEX idx_schedule_runs_schedule ON schedule_runs(schedule_id, started_at DESC);
3 changes: 3 additions & 0 deletions crates/ruscker-admin/src/alerts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ pub enum AlertKind {
/// A spec is saturated with every replica at `max-replicas` —
/// visitors are being turned away and Ruscker can't scale further.
Saturated,
/// A scheduled job (#986) exited non-zero or could not run.
JobFailed,
/// Operator-triggered delivery check.
Test,
}
Expand All @@ -79,6 +81,7 @@ impl AlertKind {
AlertKind::SpawnFailed => "spawn-failed",
AlertKind::ReplicaDown => "replica-down",
AlertKind::Saturated => "saturated",
AlertKind::JobFailed => "job-failed",
AlertKind::Test => "test",
}
}
Expand Down
1 change: 1 addition & 0 deletions crates/ruscker-admin/src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ pub mod images;
pub mod landing;
pub mod landing_blocks;
pub mod ruscker_images;
pub mod schedules;
pub mod settings;
pub mod showcase;
pub mod spec_access;
Expand Down
Loading