Scheduled jobs#
What runs on a schedule, on both deployments:
Kubernetes, the Helm chart (Deploy on Kubernetes): the two backups are CronJobs. gc and the two Claude passes need the live database, which is on the scrap pod’s emptyDir, so they run in the pod’s
jobscontainer (scrap schedule), on the same kind of cron schedule (The database on an emptyDir, with Litestream).<fullname>is the release’s full name (scrapfor a release namedscrap), shortened with a hash when it is long.A single server (Deploy on a single server): a systemd user timer for each job.
The default night, in order (times are the chart’s; each single-server timer adds up to 15 minutes of random delay). Gc looks for the backup before it deletes:
flowchart LR
classDef store fill:#e8f1ff,stroke:#4a7bd0
classDef claude fill:#fff3e0,stroke:#e08a00
B["03:30 backup"]:::store --> R["03:41 related pages"]:::claude --> G["04:30 gc"]:::store
T["Sundays 04:11 topics"]:::claude
M["1st, 03:50 monthly backup"]:::store
B -. "backup under 26 h old" .-> G
Job |
Kubernetes |
Single-server units |
Default schedule |
What it does |
Claude budget |
Deadline |
|---|---|---|---|---|---|---|
Backup |
CronJob |
|
03:30 daily, |
A backup into a new timestamped run, keeping the newest |
No |
Kubernetes: starts within 1 h, runs at most 1 h; single server: 1 h |
Monthly backup |
CronJob |
|
03:50 on the 1st, |
The same backup into a new run in the |
No |
Kubernetes: starts within 1 h, runs at most 1 h; single server: 1 h |
gc |
|
|
04:30 daily, |
|
No |
1 h |
Related pages |
|
|
03:41 daily, |
|
Yes |
Kubernetes: 4 h; single server: none |
Topics |
|
|
04:11 on Sundays, |
|
Yes (the call, and the syntheses) |
Kubernetes: 1 h; single server: none |
On Kubernetes the chart runs the database with Litestream by default
(ADR 47), so gc,
related pages and topics, which need the live database, run in the scrap pod’s jobs container,
not as CronJobs. Chart 1.9.0 rendered suspended stub CronJobs named <fullname>-gc,
<fullname>-enrich-related and <fullname>-enrich-topics for upgrades; 1.9.1 does not, so an
upgrade from the old mode needs care (Upgrading from the old mode).
On Kubernetes the jobs container also does this, on fixed times that no value changes:
Job |
Where |
When |
What it does |
|---|---|---|---|
Heartbeat |
|
every 15 minutes |
Stamps the database, so a backup (and the next pod start) can tell how old the replica is |
Replication check |
|
every minute |
With no stamp newer than 20 minutes in the replica, it logs, notifies ( |
Litestream snapshot |
|
every 6 hours, kept 24 hours |
A full copy in the replica, which shortens a restore |
scrap schedule status in the jobs container, or its Prometheus metrics, says how each job last
ran and when the newest backup completed (Are the nightly jobs healthy?). To run one now, recorded
like a scheduled run:
kubectl -n scrap exec deploy/scrap -c jobs -- scrap schedule --run gc
It exits with the job’s status, or 75 if that job is already running.
Settings#
Each chart value, its default, and what does the same on a single server. A timer drop-in is
systemctl --user edit <timer> with [Timer], an empty OnCalendar=, then the new one; a
service drop-in is systemctl --user edit <service> with [Service], an empty ExecStart=,
then the new command (both in Backup and restore, Changing the schedule and Changing
what a job does). Re-running install.sh enables again every timer whose command the image
has, so a timer turned off only with systemctl --user disable must be disabled again after
it; SCRAP_BACKUP_MONTHLY_KEEP=0 is an opt-out that install.sh keeps.
Chart value |
Default |
Single server |
|---|---|---|
|
|
|
|
|
timer drop-in on |
|
|
none: the machine’s local time |
|
|
|
|
a 20Gi claim |
|
|
|
|
|
|
timer drop-in on |
|
|
none: the machine’s local time |
|
|
|
|
see |
none: the jobs share the machine |
|
|
|
|
|
timer drop-in on |
|
|
none: the machine’s local time |
|
|
service drop-in: |
|
|
service drop-in: |
|
|
service drop-in: |
|
|
|
|
|
service drop-in: |
|
|
none: |
|
|
|
|
|
timer drop-in on |
|
|
none: the machine’s local time |
(none) |
service drop-in: |
|
|
|
|
|
|
timer drop-in on |
|
|
none: the machine’s local time |
(none) |
service drop-in: |
|
|
requests 50m and 256Mi, limit 2Gi |
none: for gc and both Claude passes together, which can overlap ( |
|
|
none: Prometheus metrics of these jobs and the backups ( |
Notes#
One budget. The Claude jobs spend from the same daily budget as photo ingest and text enrichment,
SCRAP_BUDGET_DAY_USD(ingest.budgetDayUSDin the chart, default $3 a UTC day). Each stops at a queue pause or when the day’s budget is spent, and exits non-zero then; the next run carries on. In thejobscontainer that stop is recorded aspaused, not a failure (no notification); a pause that lasts two runs makes the pass stale inscrap schedule status.Claude jobs need ingest. The chart schedules the related-pages and topics passes only while
ingest.enabledis true. A single server’s timers run regardless; while ingest or enrichment is off, or no key (or seat token) is set, the command says so and succeeds.Spacing. Backup 03:30, related pages 03:41, monthly backup 03:50 on the 1st, topics Sundays 04:11, gc 04:30 (each single-server timer with up to 15 minutes of random delay): gc comes after the backup it checks for, the two backups and gc share a lock so never overlap, and the Claude jobs usually start after the backup has its copy (nothing orders them: a slow backup may overlap).
Deadline. In the
jobscontainer, a job still running at its next time is not started again. After a gap (the pod busy or briefly stopped), one run stands for the times missed, if one of them was within the last 60 minutes; a time missed while the pod was down longer is not made up. A rollout stops a running job, and the next run carries on. A run past its deadline is stopped (SIGTERM, then SIGKILL after 10 s) and recorded asdeadline. The backup CronJobs are skipped if they cannot start within an hour of their time (startingDeadlineSeconds) and stopped after an hour’s run (activeDeadlineSeconds). On a single server, the backup, monthly backup and gc services stop after an hour (TimeoutStartSec); the Claude ones have no limit.Finished Jobs. In the chart, each backup CronJob keeps its last 3 successful and 3 failed Jobs, and Kubernetes deletes any finished Job, with its pod, 7 days after it ends (
ttlSecondsAfterFinished). That includes one-off Jobs made withkubectl create job --from=cronjob/..., such as the pre-release backup. gc and the Claude passes are not Jobs: their runs are recorded in the database (scrap schedule status). Each Deployment keeps 2 old ReplicaSets (revisionHistoryLimit).Time zone. In the chart, an empty
timeZoneis the controller’s zone (usually UTC) for the two backup CronJobs, and UTC for the jobs in the scrap pod. Set an IANA name such asEurope/Londonto change either. A single server’s timers use the machine’s local time.Single-server schedules. Change one with a timer drop-in, which
install.shkeeps:systemctl --user edit scrap-backup.timer, then clearOnCalendarbefore the new one (Backup and restore, Changing the schedule). The same works for every timer.