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

fixes intermittent multiple job invocations #41

Merged
merged 1 commit into from
Jun 13, 2022
Merged

fixes intermittent multiple job invocations #41

merged 1 commit into from
Jun 13, 2022

Conversation

lprimak
Copy link
Contributor

@lprimak lprimak commented Apr 9, 2022

Fixes #32 and #27

  • [X ] Ensure that the pull request title represents the desired changelog entry
  • [X ] Please describe what you did
  • [ X] Link to relevant issues in GitHub or Jira

fixes intermittent multiple job invocatino
@bluesliverx
Copy link
Contributor

@lprimak, thanks for the contribution! Interesting that this is causing the problems, but I can see how possibly it could trigger a job twice if two SCM owners were attached to it and they both match. However, what happens here when there are legitimately multiple SCM sources that point at the same repository? In our Jenkins we have multiple jobs pointing at the same GitHub source repository. This changes plugin behavior in a way that would break the functionality for that use case I believe.

Can you provide more details on how this fixes the problem?

@lprimak
Copy link
Contributor Author

lprimak commented Apr 12, 2022

There is only one SCM owner. The issue is intermittent.
I believe there is some kind of race condition in the event push logic in Jenkins causing two jobs to be selected in the loop.

I can see where a subtle cases could have the legitimate second job not being triggered.
However, I do believe that for 99% of the cases, this fix would work.
In my setup, duplicate builds happen about 30% of the time tests are triggered,
so you can imagine this can get pretty frustrating for the "normal" use case.

I do understand this change may not be acceptable. Do you have another suggestion?
Does .equals() on Job<?,?> work correctly? Would putting in a Set<> work to make the jobs unique?

@lprimak
Copy link
Contributor Author

lprimak commented Jun 8, 2022

@bluesliverx what do you think of above? thanks!

@bluesliverx
Copy link
Contributor

Well, I'm honestly not sure how this fixes it, but I'm willing to try it. If it ends up causing issues in our build system though (such as missed triggers), I'll need to revert it. But let's give it a shot :)

@bluesliverx bluesliverx merged commit 40b920e into jenkinsci:master Jun 13, 2022
@lprimak
Copy link
Contributor Author

lprimak commented Jun 13, 2022

Thanks!

@bluesliverx
Copy link
Contributor

Released in https://github.com/jenkinsci/github-pr-comment-build-plugin/releases/tag/67.va90f5cae5912

@@ -161,13 +162,14 @@ public void run() {
changedRepository.getRepositoryName()
}
);
break topLevel;

Choose a reason for hiding this comment

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

Sadly this has broken the following workflow, in which we expect multiple builds to be triggered:

  • we have multiple jobs which each define triggerPRCommentBranchProperty e.g. one with commentBody(".*foo this please.*") and another with commentBody(".*bar this please.*")
  • it was previously possible to comment on a PR like this and both jobs would be triggered:
foo this please
bar this please
  • however now only 1 of them is triggered (whichever one the for (Job... loop gets to first)

The workaround is of course to do a separate comment for each one, but when you want to trigger 5 different custom test runs, this is a 5x increase in (a) effort to initiate, and (b) the amount of email spam sent to others watching the PR.

Perhaps if instead of doing break it instead checked whether job had already been scheduled, that would be a way of avoiding duplicates without stopping multiple different jobs being scheduled from the same comment?

Copy link
Contributor

Choose a reason for hiding this comment

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

We have been seeing issues for weeks with similar problems, and your comment just made me connect it to this PR. I'm downgrading the plugin on our Jenkins to verify that this is indeed the cause.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sparrowt please open a new issue.
As I mentioned in the comment #41 (comment),
this would break the cases where multiple legitimate jobs would be triggered by a single comment.
Unfortunately I don't have the environment to test this on.
This PR fixes the 99% case where this plugin was broken for a long time, as reported in multiple issues by multiple people.

I can propose a short-term fix by adding a checkbox that turns off one-per-comment build (default would be on) since that's 99% of the cases.

In the future if there is more interest to see what actually causes duplicate builds maybe there would be more time to take this on

Copy link

Choose a reason for hiding this comment

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

Sorry I never got round to this - however it looks like #49 was opened and #48 fixes it (released in https://github.com/jenkinsci/github-pr-comment-build-plugin/releases/tag/82.v986d7874d9c5) so thank you!

@lprimak
Copy link
Contributor Author

lprimak commented Aug 19, 2022

@bluesliverx please don't revert this. It breaks the 99% cases for this plugin.
I have time to put in a checkbox

@bluesliverx
Copy link
Contributor

@lprimak sorry I've been out due to some personal things at home. I'm not planning on reverting this necessarily. I was saying that I downgraded the version that was installed on our Jenkins cluster to see if it helped, and it did indeed, so this is definitely the troublesome commit.

I like the solution proposed by someone else, look at the queue to see if it was already scheduled for the job to prevent multiple starts for a single job.

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

Successfully merging this pull request may close these issues.

This plugin triggers the build twice
3 participants