Skip to content

fix: gate multi-parent jobs on all predecessors and tolerate generated depends_on in batch config - #2767

Open
kornelwencek-esky wants to merge 1 commit into
diggerhq:developfrom
kornelwencek-esky:fix/backend-multi-parent-job-gating
Open

kornelwencek-esky wants to merge 1 commit into
diggerhq:developfrom
kornelwencek-esky:fix/backend-multi-parent-job-gating

Conversation

@kornelwencek-esky

Copy link
Copy Markdown

Description

Fixes #2765
Fixes #2764

Two backend problems made depends_on between a static project and projects generated by generate_projects unusable (observed live on a self-hosted backend):

  1. Multi-parent job gating (Multi-parent depends_on: dependent job is gated on one predecessor only (CollapsedGraph drops parent edges) #2765): CollapsedGraph returned early when the child vertex already existed, keeping only one (traversal-order dependent) incoming edge for a multi-parent child; ConvertJobsToDiggerJobs created one child job row per parent edge. A dependent job could start and complete while its predecessors were still running.

  2. Batch config reload (Backend batch paths fail to convert digger.yml when a static project uses depends_on on a generated project #2764): backend batch paths that only read top-level settings (aggregate check run update, automerge check, terraform outputs summary, prior-comment deletion) re-converted the stored digger.yml without running generate_projects and failed the strict depends_on validation, leaving the aggregate digger/plan check stuck and posting a warning comment after every job status update.

Changes

  • CollapsedGraph: add the parent -> child edge even when the child vertex already exists (tolerate ErrEdgeAlreadyExists); children are still processed only once
  • ConvertJobsToDiggerJobs: create the child job once and link every parent job to it, so gating waits for all predecessors
  • libs/digger_config: new ConvertDiggerYamlToConfigWithoutDependencyValidation for callers that parse a raw digger.yml without generation; ConvertDiggerYamlToConfig behavior is unchanged
  • the four backend batch paths that only read top-level settings now use the lenient variant

Tests

  • regression test: the collapsed graph keeps an edge from every impacted parent (fails on develop: "Expected child to have 3 predecessors, got 1")
  • regression test (sqlite): a multi-parent child results in exactly one job row linked to all parents (fails on develop: one job row per parent edge)
  • new test: strict conversion rejects missing depends_on targets, the lenient variant succeeds

go test ./backend/utils/ ./backend/models/ ./backend/controllers/ and the libs/digger_config tests pass locally.

Note: gofmt/go vet flag pre-existing issues in backend/controllers/projects.go (double blank line at ~line 1124, unkeyed struct literals) that exist on develop as well and are left untouched here.

🧠 Ai UsageDetails (if applicable):

Used an AI coding assistant to draft the fixes and tests; reviewed and verified manually, all tests run locally.

…d depends_on in batch config

Two backend problems made depends_on between a static project and
projects generated by generate_projects unusable:

1. Multi-parent job gating (fixes diggerhq#2765): CollapsedGraph returned
   early when the child vertex already existed, keeping only one
   incoming edge for a multi-parent child; ConvertJobsToDiggerJobs
   created one child job row per parent edge. A dependent job could
   start and complete while its predecessors were still running.
   Now the edge is added even when the vertex exists, and the child
   job is created once and linked to every parent job.

2. Batch config reload (fixes diggerhq#2764): backend batch paths that only
   read top-level settings (aggregate check run update, automerge
   check, terraform outputs summary, prior-comment deletion)
   re-converted the stored digger.yml without running generate_projects
   and failed strict depends_on validation. A new
   ConvertDiggerYamlToConfigWithoutDependencyValidation skips that
   validation for those callers; the strict conversion is unchanged.
@kornelwencek-esky
kornelwencek-esky marked this pull request as ready for review November 4, 2026 11:43

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant