Display downstream pipeline errors in upstream pipelines (UX improvement)
Summary
When triggering downstream pipelines they can error out. We should be able to display these errors in the upstream bridge job.
Proposal
We can reach failure reasons of downstream pipelines via Ci::Bridge#sourced_pipelines
.
However, we don't always create downstream pipelines. Examples:
After implementing #213666 (closed), in this issue, we need store failure reason information of downstream pipelines in bridges. (More discussions about it: !28120 (comment 312091893))
Then we can have this behavior:
We also need to add failure reason for strategy:depend situations. We may do this in another issue/MR.
Discussion: !28120 (comment 318999395)
I would also consider adding
downstream_pipeline_failed
failure reason to a the list of failure reasons supported byCi::Bridge
. It seems like a small effort, and might improve the situation here significantly. We probably would need to add this toself.drop!(...)
inCi::Bridge#inherit_status_from_downstream
Old Proposal
- Persist all pipeline creation errors in
Ci::Pipeline
model. Maybe we can reuseCi::Pipeline#yaml_errors
and rename it toCi::Pipeline#creation_errors
? - When creating a downstream pipeline we now persist always the association between bridge job and downstream pipeline, so we can always reference the downstream pipeline from the bridge job.
- Change
Gitlab::Ci::Status::Build::Failed#failure_reason_message
to append related downstream pipeline errors iffailure_reason_message
is called to display bridge job errors.
We could look into changing the failure_reason_message
to append any additional errors from the downstream pipeline.
class Ci::Status::Build::Failed
def failure_reason_message
messages = []
messages << self.class.reasons.fetch(subject.failure_reason.to_sym)
messages += subject.additional_errors
messages.join(', ')
end
end
class Ci::Bridge
def additional_errors
return [] unless failure_reason == 'downstream_bridge_pipeline_creation_failed'
# this is not performant and queries need to be optimized
sourced_pipelines.map do |source_pipeline|
source_pipeline.pipeline.yaml_errors
end
end
end
class Ci::Build
def additional_errors
[]
end
end
Technical Background
When triggering a downstream pipeline with a bridge job - if the downstream pipeline creation errors out (e.g. an invalid YAML config), the relationship between the bridge job and the downstream pipeline is not saved.
This is because the relation is being added in the `Seed` pipeline chain step and the chain is broken in `Confing::Content` or `Config::Process` which comes before `Seed`.
This is required for displaying the downstream creation errors in upstream bridges.
This was resolved with #207234 (closed)