Skip to content

Display running pipelines that did not pass through the build queue#502

Merged
nikita-tkachenko-datadog merged 1 commit into
masterfrom
nikita-tkachenko/display-running-pipelines-that-werent-queued
Feb 6, 2025
Merged

Display running pipelines that did not pass through the build queue#502
nikita-tkachenko-datadog merged 1 commit into
masterfrom
nikita-tkachenko/display-running-pipelines-that-werent-queued

Conversation

@nikita-tkachenko-datadog

@nikita-tkachenko-datadog nikita-tkachenko-datadog commented Feb 6, 2025

Copy link
Copy Markdown
Collaborator

Requirements for Contributing to this repository

  • Fill out the template below. Any pull request that does not include enough information to be reviewed in a timely manner may be closed at the maintainers' discretion.
  • The pull request must only fix one issue at the time.
  • The pull request must update the test suite to demonstrate the changed functionality.
  • After you create the pull request, all status checks must be pass before a maintainer reviews your contribution. For more details, please see CONTRIBUTING.

What does this PR do?

Ensures that (arguably) malformed pipelines that seem to be neither scripted nor declarative are displayed in Datadog - not only once finished, but also while running.

The way running pipelines work is that the plugin submits a pipeline to the backend once it has started, and later submits the same pipeline once it has finished - the backend updates pipeline record and the pipeline status changes in the UI.
The caveat with the running pipelines is that Datadog backend requires that a pipeline start time never changes: there are some technical limitations related to how pipeline data is stored, due to which the start time needs to be constant.
The problem is that the true start time of a pipeline is only known while the pipeline has left the build queue (while the pipeline is in the queue it has not started running yet), which for some pipelines happens after pipeline listeners have been invoked (this concerns the build listener, the graph listener, the step listener, the SCM checkout listener - all of these listeners may fire before pipeline leaves the build queue).

To ensure that the start time does not change the plugin does not submit pipeline data to the backend if the timestamp of that pipeline leaving the build queue is not known yet.
The problem is that some pipelines are executed without being added to the build queue.
Here is an example of such pipeline (missing the pipeline {} and the node {} top-level blocks):

echo "This is a step that doesn't belong to any stage"

stage("Bootstrap") {
    echo "And this is a regular step"
}

echo "This is another step that doesn't belong to any stage"

The workaround introduced in this PR is: when the DatadogStepListener detects that a pipeline step has started executing, it checks the queue time data - if the data was not filled and the pipeline is executing already, it means that the pipeline missed the build queue. For such pipelines the queue time is set to 0.

Description of the Change

Alternate Designs

Possible Drawbacks

Verification Process

Additional Notes

Release Notes

Review checklist (to be filled by reviewers)

  • Feature or bug fix MUST have appropriate tests (unit, integration, etc...)
  • PR title must be written as a CHANGELOG entry (see why)
  • Files changes must correspond to the primary purpose of the PR as described in the title (small unrelated changes should have their own PR)
  • PR must have one changelog/ label attached. If applicable it should have the backward-incompatible label attached.
  • PR should not have do-not-merge/ label attached.
  • If Applicable, issue must have kind/ and severity/ labels attached at least.

@nikita-tkachenko-datadog nikita-tkachenko-datadog added the changelog/Fixed Fixed features results into a bug fix version bump label Feb 6, 2025
@nikita-tkachenko-datadog
nikita-tkachenko-datadog marked this pull request as ready for review February 6, 2025 16:35

@drodriguezhdez drodriguezhdez left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@nikita-tkachenko-datadog
nikita-tkachenko-datadog merged commit cd1378e into master Feb 6, 2025
@nikita-tkachenko-datadog
nikita-tkachenko-datadog deleted the nikita-tkachenko/display-running-pipelines-that-werent-queued branch February 6, 2025 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog/Fixed Fixed features results into a bug fix version bump

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants