-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Introducing ControllerToAgentCallable and ControllerToAgentFileCallable
#9921
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
Conversation
| } | ||
|
|
||
| @Restricted(NoExternalUse.class) | ||
| public void setEnvVarsFilterRuleWrapper(EnvVarsFilterRuleWrapper envVarsFilterRuleWrapper) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@daniel-beck in #4683 you added this as a setter rather than constructor parameter, perhaps out of confusion with the similarly-named field in Launcher which actually needs to be mutable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe, the original code is by Wadeck and it's been far too long at this point. If this works, the setter is restricted, so any cleanup is fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the setter is restricted
Not that it needed to be: the class was private to begin with.
…ntrollerToAgentCallable
ControllerToAgentCallableControllerToAgentCallable and ControllerToAgentFileCallable
core/src/main/java/jenkins/agents/ControllerToAgentCallable.java
Outdated
Show resolved
Hide resolved
| * For new code, implement {@link ControllerToAgentFileCallable} | ||
| * which has the advantage that it can be used on {@code record}s. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that, should this class be deprecated to discourage any new usage, or hint existing ones to move to records?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose it could be, though it feels like overkill to deprecate it merely because an aesthetically preferable alternative is now available.
Co-authored-by: Vincent Latombe <[email protected]>
timja
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
/label ready-for-merge
This PR is now ready for merge, after ~24 hours, we will merge it if there's no negative feedback.
Thanks!
While updating some plugin code to take advantage of Java 17
records, I noticed that one major use case for astatic final classwith allfinalfields wasMasterToSlaveCallables. Unfortunately these cannot be converted torecordsince that cannotextendanotherclass. I thought it would be nicer to introduce a similarinterface(with updated naming, while we are here!) that is friendlier torecords.I picked
RemoteLaunchCallableas an example of substantial legibility improvements from this conversion, but could try doing more as well. (OpenRewrite would be great though I am not experienced in that yet.)Similarly,
MasterToSlaveFileCallablewas unnecessarily awkward to use;FilePath.Archivecan be simplified this way as an example.Testing done
None, just presuming that
RemoteLaunchCallableandFilePath.Archiveare well covered by existing functional tests.Note that the version of SpotBugs we are currently running suffers from spotbugs/spotbugs#2795 which is relevant for this use case: these
records areSerializable(transiently), but noserialVersionUIDis meaningful since Java serialization forrecords is handled specially. The SpotBugs check forjenkins-coredoes not seem to complain for whatever reason (maybe this bug priority is already suppressed?); in my plugin doing similar work I needed toI do not feel very comfortable with the idea of reducing the typical idiom further to that using a
staticmethod as in jenkinsci/jenkins-test-harness#671 because production code might involve different Java versions (or even vendors!) between controller and agent and it is not obvious to me that this would be safe. Givenyou can see a rather complex serial form
Proposed changelog entries
ControllerToAgentCallableandControllerToAgentFileCallablewith support forrecordsin controller to agent callablesProposed upgrade guidelines
N/A
Desired reviewers
@Vlatombe @nevingeorgesunny @gbhat618
Before the changes are marked as
ready-for-merge: