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

Extract interfaces for objects to be used through the executors widget #9749

Merged
merged 19 commits into from
Oct 2, 2024

Conversation

Vlatombe
Copy link
Member

@Vlatombe Vlatombe commented Sep 18, 2024

This is required for CloudBees CI HA support: we provide alternate implementations of these interfaces to represent computers and related objects that exist in different physical replicas of the same logical instance.

This allows to build an aggregated view of computers and executors, some local, some remote.

To avoid wording conflicts with existing concrete classes, the new interfaces are prefixed with I e.g. IComputer. I'm open to alternative naming suggestions, but unfortunately the names that would represent them the most accurately are already taken.

This introduces a new extension point, ComputerSource, allowing to override the list of computers that is returned via ComputerSet. Only the implementation with the highest ordinal among those registered will be picked up. The default implementation returns local Computer instances, and has ordinal -1, allowing a plugin to override it with a simple @Extension without any explicit ordinal being set.

See JENKINS-XXXXX.

Testing done

Proposed changelog entries

  • N/A

Proposed upgrade guidelines

N/A

Submitter checklist

Desired reviewers

@mention

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

Maintainer checklist

This is required for CloudBees CI HA support: we provide alternate implementations of these interfaces to represent computers and related objects that exist in different physical replicas of the same logical instance. This allows to be build an aggregated view of computers and executors, some local, some remote.
@Vlatombe Vlatombe requested review from jglick and a team September 18, 2024 11:38
@Vlatombe Vlatombe added the skip-changelog Should not be shown in the changelog label Sep 18, 2024
Comment on lines -1730 to -1737
/**
* A value class to provide a consistent snapshot view of the state of an executor to avoid race conditions
* during rendering of the executors list.
*
* @since 1.607
*/
@Restricted(NoExternalUse.class)
public static class DisplayExecutor implements ModelObject {
Copy link
Member Author

Choose a reason for hiding this comment

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

Moved to its own file.

return executor.equals(that.executor);
}

@Extension(ordinal = Double.MAX_VALUE)
Copy link
Member Author

Choose a reason for hiding this comment

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

(ignore WS)

Comment on lines -1959 to -1976
/**
* Works just like {@link #checkAbortPermission()} except it indicates the status by a return value,
* instead of exception.
* Also used by default for {@link hudson.model.Queue.Item#hasCancelPermission}.
* <p>
* NOTE: If you have implemented {@link AccessControlled} this returns by default
* {@code return hasPermission(hudson.model.Item.CANCEL);}
*
* @return false
* if the user doesn't have the permission.
*/
default boolean hasAbortPermission() {
if (this instanceof AccessControlled) {
return ((AccessControlled) this).hasPermission(CANCEL);
}
return true;
}

Copy link
Member Author

Choose a reason for hiding this comment

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

Moved to ITask

Copy link
Member

@jglick jglick left a comment

Choose a reason for hiding this comment

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

Minor questions about Javadoc and nullability.

core/src/main/java/hudson/model/Computer.java Outdated Show resolved Hide resolved
core/src/main/java/jenkins/model/IComputer.java Outdated Show resolved Hide resolved
core/src/main/java/jenkins/model/queue/ITask.java Outdated Show resolved Hide resolved
core/src/main/java/jenkins/model/queue/ITask.java Outdated Show resolved Hide resolved
core/src/main/java/jenkins/model/queue/ITask.java Outdated Show resolved Hide resolved
core/src/main/java/jenkins/model/queue/ITask.java Outdated Show resolved Hide resolved
*/
@Exported
public String getIconClassName() {
return getIcon();
return IComputer.super.getIconClassName();
Copy link
Member Author

Choose a reason for hiding this comment

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

Only here for @Exported

Comment on lines -43 to -47
* <p>
* Plugins are encouraged to extend from {@link AbstractSubTask}
* instead of implementing this interface directly, to maintain
* compatibility with future changes to this interface.
*
Copy link
Member Author

@Vlatombe Vlatombe Sep 18, 2024

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

#2879 FTR

Copy link
Member

@jglick jglick left a comment

Choose a reason for hiding this comment

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

Still unsure about ITask.getUrl (#9749 (comment)).

Comment on lines -43 to -47
* <p>
* Plugins are encouraged to extend from {@link AbstractSubTask}
* instead of implementing this interface directly, to maintain
* compatibility with future changes to this interface.
*
Copy link
Member

Choose a reason for hiding this comment

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

#2879 FTR

Copy link
Member

@jglick jglick left a comment

Choose a reason for hiding this comment

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

#9749 (comment) still unclear

core/src/main/java/jenkins/model/IComputer.java Outdated Show resolved Hide resolved
core/src/main/java/jenkins/model/IComputer.java Outdated Show resolved Hide resolved
@Vlatombe
Copy link
Member Author

/label ready-for-merge


This PR is now ready for merge, after the pending security release, we will merge it if there's no negative feedback.

Thanks!

@comment-ops-bot comment-ops-bot bot added the ready-for-merge The PR is ready to go, and it will be merged soon if there is no negative feedback label Sep 25, 2024
@Vlatombe Vlatombe requested a review from jglick October 2, 2024 07:19
@MarkEWaite MarkEWaite merged commit 39e6622 into master Oct 2, 2024
17 checks passed
@MarkEWaite MarkEWaite deleted the executors branch October 2, 2024 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-for-merge The PR is ready to go, and it will be merged soon if there is no negative feedback skip-changelog Should not be shown in the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants