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

Job.BuildNumberAssigner #9846

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

jglick
Copy link
Member

@jglick jglick commented Oct 8, 2024

In CloudBees CI in high availability mode, the default behavior of Job.assignBuildNumber (updating a counter in memory, and writing it to disk) is not suitable for rapid build triggers of a single job; an external counter is needed at least transiently (the nextBuildNumber file is fine for a durable count). This beta extension point allows a plugin to swap in an alternate strategy for maintaining the next build number.

The BuildNumberAssignment return type is a bit awkward but I could not think of a better API. Job.saveNextBuildNumber is protected, so not usable from alternate implementations, and I did not want to make it public solely for the benefit of a beta API. (Introducing a public alias also seemed weird.) The method introduced in #9019 does not save, whereas the older updateNextBuildNumber method remains undesirable here because of its call to getLastBuild. Automatically calling saveNextBuildNumber from assignBuildNumber would change sychronization behavior for the default implementation, and making assignBuildNumber be synchronized would be undesirable for the CloudBees CI implementation. Reworked, I hope more clearly.

This PR makes #9778 not strictly necessary but I think it remains appropriate anyway.

Testing done

Effectiveness confirmed by a functional test in CloudBees CI.

Proposed changelog entries

  • N/A

Before the changes are marked as ready-for-merge:

Maintainer checklist

@jglick jglick requested a review from Vlatombe October 8, 2024 19:54
@jglick jglick requested a review from Vlatombe October 9, 2024 14:23
Copy link
Member

@Vlatombe Vlatombe left a comment

Choose a reason for hiding this comment

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

LGTM

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.

2 participants