Skip to content

Job dependencies (simple): only run if parent job succeeded recently #79

Description

@csoscd

Summary

Allow a job to declare a single parent job as a dependency. The job is skipped at execution time if the parent did not succeed within a configurable time window.

Motivation / Use Case

Common for sequential workflows: a "verify backup" job should only run if the preceding "create backup" job succeeded. Currently this requires external scripting or manual scheduling gaps.

Proposed Behaviour

  • Each job can optionally specify one parent job and a "must have succeeded within N minutes" window
  • At execution start, cron-wrapper.sh checks the parent's last execution result
  • If the condition is not met, the job is skipped and recorded as "Skipped (dependency not met)" in the execution history (similar to the singleton-skipped status from issue Singleton guard: show 'skipped (singleton)' as distinct status in execution history #75)
  • No change to the cron schedule itself — the dependency check is runtime, not schedule-level
  • Circular dependency detection at save time (UI + agent validation)

Affected Component

  • cron-wrapper.sh
  • Agent
  • Web UI

First Implementation Idea

  1. Schema — add depends_on_job_id (nullable FK → cronjobs.id) and depends_on_max_age_minutes (int, default 60) to the cronjobs table; new migration file.
  2. New agent endpointGET /crons/{id}/dependency-check returns {"satisfied": true/false, "reason": "..."} based on querying the most recent successful root execution (retry_attempt = 0, exit_code = 0) of the parent within the configured window.
  3. cron-wrapper.sh — after the singleton check and before fetching the command, call the dependency-check endpoint. On satisfied: false, POST /execution/start + /execution/finish with exit code -7 ("Skipped – dependency not met") and exit.
  4. CronGetEndpoint — include depends_on_job_id and depends_on_max_age_minutes in the job payload.
  5. Web UI — job form gains a "Depends on" dropdown (job selector) and a "within N minutes" input; only shown when a parent is selected. Circular dependency validated on save.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions