Skip to content

Backend: Deprecate `sourced_pipelines` in bridge/job in favour of `sourced_pipeline`

Problem

The relation has_many :sourced_pipelines defined in Ci::Bridge and Ci::Build is not correct because a job can only trigger 1 downstream pipeline. This could cause confusion as well as data inconsistency if we ever end up having multiple downstream pipelines for a given job. This data inconsistency was in fact experienced recently in #205705 (closed) and contributed to a major issue on production.

Solution

We have introduced has_one :sourced_pipeline in Ci::Bridge as part of !31370 (merged) to make explicit that bridge has_one :downstream_pipeline.

We should move the relation to Ci::Processable, so that both bridge and build have 1 sourced pipeline, and deprecate sourced_pipelines relationship.

Update [2022-12-01]

The removal of the has_many :sourced_pipelines relationship caused a regression (see #384053 (closed)) as it was discovered that some customers are triggering multiple downstream pipelines from a single Build job via the API (using CI_JOB_TOKEN).

We reverted the removal and decided to:

Maintain this difference between trigger (1 downstream pipeline) and builds (many downstream pipelines).

New Solution

Remove the has_many :sourced pipelines relationship for only Bridge jobs, and have the change made behind a feature flag for safe measure.

Implementation

backend Ref
Move has_one :sourced_pipeline relation to CI::Processable !103555 (merged)
Remove has_many: sourced_pipelines association in CI bridge/build job [REVERTED in !105490 (merged)] !103980 (merged)
Remove sourced_pipelines association for Bridge jobs. Feature flag: :ci_bridge_remove_sourced_pipelines !105708 (merged)
[Feature flag] Roll out ci_bridge_remove_sourced_pipelines Issue #384359 (closed)
Remove ci_bridge_remove_sourced_pipelines feature flag !107121 (merged)
Edited by Leaminn Ma