Skip to content

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.

Screen_Shot_2020-04-07_at_15.07.38

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:

Screen_Shot_2020-03-26_at_17.49.17


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 by Ci::Bridge. It seems like a small effort, and might improve the situation here significantly. We probably would need to add this to self.drop!(...) in Ci::Bridge#inherit_status_from_downstream


Old Proposal
  1. Persist all pipeline creation errors in Ci::Pipeline model. Maybe we can reuse Ci::Pipeline#yaml_errors and rename it to Ci::Pipeline#creation_errors?
  2. 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.
  3. Change Gitlab::Ci::Status::Build::Failed#failure_reason_message to append related downstream pipeline errors if failure_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)

Use cases to solve

Edited by Thao Yeager