Skip to content

Commit

Permalink
Follow-up fixes to Nodes refactoring (#9053)
Browse files Browse the repository at this point in the history
  • Loading branch information
jglick committed Mar 24, 2024
1 parent 5cec09d commit c3e3a4a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
6 changes: 3 additions & 3 deletions core/src/main/java/hudson/model/Queue.java
Original file line number Diff line number Diff line change
Expand Up @@ -1751,7 +1751,7 @@ private Runnable makeFlyWeightTaskBuildable(final BuildableItem p) {
Label lbl = p.getAssignedLabel();

Computer masterComputer = h.toComputer();
if (lbl != null && lbl.equals(h.getSelfLabel())) {
if (lbl != null && lbl.equals(h.getSelfLabel()) && masterComputer != null) {
// the flyweight task is bound to the master
if (h.canTake(p) == null) {
return createFlyWeightTaskRunnable(p, masterComputer);
Expand All @@ -1760,7 +1760,7 @@ private Runnable makeFlyWeightTaskBuildable(final BuildableItem p) {
}
}

if (lbl == null && h.canTake(p) == null && masterComputer.isOnline() && masterComputer.isAcceptingTasks()) {
if (lbl == null && h.canTake(p) == null && masterComputer != null && masterComputer.isOnline() && masterComputer.isAcceptingTasks()) {
// The flyweight task is not tied to a specific label, so execute on master if possible.
// This will ensure that actual agent disconnects do not impact flyweight tasks randomly assigned to them.
return createFlyWeightTaskRunnable(p, masterComputer);
Expand Down Expand Up @@ -1794,7 +1794,7 @@ private Runnable makeFlyWeightTaskBuildable(final BuildableItem p) {
return null;
}

private Runnable createFlyWeightTaskRunnable(final BuildableItem p, final Computer c) {
private Runnable createFlyWeightTaskRunnable(final BuildableItem p, final @NonNull Computer c) {
if (LOGGER.isLoggable(Level.FINEST)) {
LOGGER.log(Level.FINEST, "Creating flyweight task {0} for computer {1}",
new Object[]{p.task.getFullDisplayName(), c.getName()});
Expand Down
3 changes: 0 additions & 3 deletions core/src/main/java/jenkins/model/Nodes.java
Original file line number Diff line number Diff line change
Expand Up @@ -332,9 +332,6 @@ public Node getNode(String name) {
*/
public void load() throws IOException {
final File nodesDir = getRootDir();
if (!nodesDir.exists()) {
return;
}
final File[] subdirs = nodesDir.listFiles(File::isDirectory);
final Map<String, Node> newNodes = new TreeMap<>();
if (subdirs != null) {
Expand Down

0 comments on commit c3e3a4a

Please sign in to comment.