Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store DownstreamBuildAction on Run instead of FlowNode for consistent persistence even on completed builds #128

Merged
merged 4 commits into from
Dec 14, 2023

Conversation

dwnusbaum
Copy link
Member

See #127 (comment).

CC @Artmorse

Testing done

Submitter checklist

@dwnusbaum dwnusbaum added the bug label Dec 14, 2023
@dwnusbaum dwnusbaum requested a review from a team as a code owner December 14, 2023 16:25
@jglick jglick marked this pull request as draft December 14, 2023 17:46
@dwnusbaum dwnusbaum changed the title Make DownstreamBuildAction immutable to fix persistence across restarts in some cases Store DownstreamBuildAction on Run instead of FlowNode for consistent persistence even on completed builds Dec 14, 2023
}
downstreamAction.setBuild(run);
run.save();
upstream.save();
Copy link
Member Author

Choose a reason for hiding this comment

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

Comment this out and downstreamBuildActionUpstreamCompletesBeforeDownstreamStarts will fail.

@dwnusbaum dwnusbaum marked this pull request as ready for review December 14, 2023 18:27
this.jobFullName = job.getFullName();
public static @NonNull DownstreamBuild getOrCreate(@NonNull Run<?, ?> run, @NonNull String flowNodeId, @NonNull Item job) {
DownstreamBuildAction downstreamBuildAction;
synchronized (DownstreamBuildAction.class) {
Copy link
Member Author

@dwnusbaum dwnusbaum Dec 14, 2023

Choose a reason for hiding this comment

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

Unnecessary in the normal case since the relevant part of BuildTriggerStepExecution runs synchronously on the CPS VM thread, but if there are queued triggered builds when updating Jenkins to pick up this PR or when Jenkins crashes then there is a possibility of race conditions leading to multiple instances of DownstreamBuildAction without some kind of synchronization. We could drop the synchronization if we don't care about that case though.

Copy link
Member

Choose a reason for hiding this comment

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

May as well keep it, does not add much clutter.

@jglick
Copy link
Member

jglick commented Dec 14, 2023

@dwnusbaum
Copy link
Member Author

dwnusbaum commented Dec 14, 2023

Not sure if https://github.com/jenkinsci/pipeline-build-step-plugin/pull/128/checks?check_run_id=19658148636 is related; maybe independently flaky?

I am not sure. It passes locally but has failed twice in CI in this PR, once on Windows before the BOM update, and once on Linux after the BOM update. In both cases the problem seems to be that the downstream build never finishes (it seems to get stuck on a semaphore step even after a call to SemaphoreStep.success). It does not seem obviously related to this PR.

BuildTriggerStepRestartTest.restartBetweenJobs also failed in an earlier build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants