Fix error status propagation to take into account catch/catchError/warnError blocks#343
Merged
nikita-tkachenko-datadog merged 3 commits intoMay 31, 2023
Conversation
drodriguezhdez
approved these changes
May 31, 2023
drodriguezhdez
approved these changes
May 31, 2023
nikita-tkachenko-datadog
deleted the
nikita-tkachenko/fix-error-status-propagation
branch
May 31, 2023 10:05
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requirements for Contributing to this repository
What does this PR do?
This PR fixes logic that propagates errors from pipeline nodes to their parents.
The problem is that currently errors are propagated unconditionally from a node to its ancestors until the root node is reached.
This approach is not always correct, as an error in the pipeline might be caught and suppressed, in which case Jenkins can report as successful the stage that caught the error (along with all its parents).
The desired state is to have statuses of the spans sent to Datadog exactly the same as the statuses of corresponding Jenkins pipeline stages, which means the logic should be adjusted to stop propagation if the error was caught.
The motivation to change this now is that there is a customer complaining about the statuses disparity.
Description of the Change
There are 3 ways to catch and suppress an error:
try/catchblock in a scripted pipelinecatchErrorblock in a declarative pipelinewarnErrorblock in a declarative pipelineFor the latter two
BuildPipelineNodeclass was augmented with an additional field that stores the status that should be applied if an error occurs in that node (withcatchErrorthis status can be configured, withwarnErrorthe status is alwaysunstable).For the first one, existing field
BuildPipelineNode#errorObjis examined: if an error is caught and suppressed, the node that caught it will havenullin that field.Alternate Designs
Possible Drawbacks
Verification Process
Verified manually with a local Jenkins instance and DD staging, and covered with integration tests that contain examples of pipelines where errors are caught using different ways.
Additional Notes
Release Notes
Review checklist (to be filled by reviewers)
changelog/label attached. If applicable it should have thebackward-incompatiblelabel attached.do-not-merge/label attached.kind/andseverity/labels attached at least.