提交 6de74a5b 编写于 作者: K Kohsuke Kawaguchi

Fied a couple of places where Task.getAssignedLabel() was invoked directly...

Fied a couple of places where Task.getAssignedLabel() was invoked directly without checking LabelAssignmentAction
上级 6e87aca5
......@@ -303,7 +303,7 @@ public abstract class Node extends AbstractModelObject implements Reconfigurable
* @since 1.413
*/
public CauseOfBlockage canTake(Queue.BuildableItem item) {
Label l = item.task.getAssignedLabel();
Label l = item.getAssignedLabel();
if(l!=null && !l.contains(this))
return CauseOfBlockage.fromMessage(Messages._Node_LabelMissing(getNodeName(),l)); // the task needs to be executed on label that this node doesn't have.
......
......@@ -14,7 +14,10 @@ import hudson.model.queue.SubTask;
*/
public interface LabelAssignmentAction extends Action {
/**
* Reassigns where the task gets run.
*
* @param task
* Never null.
* @return
* null to let other {@link LabelAssignmentAction}s take control, eventually to {@code SubTask#getAssignedLabel()}.
* If non-null value is returned, that label will be authoritative.
......
......@@ -34,6 +34,7 @@ import hudson.model.Queue.BuildableItem;
import hudson.model.Queue.Executable;
import hudson.model.Queue.JobOffer;
import hudson.model.Queue.Task;
import hudson.model.labels.LabelAssignmentAction;
import java.util.AbstractList;
import java.util.ArrayList;
......@@ -181,7 +182,7 @@ public class MappingWorksheet {
super(base);
assert !base.isEmpty();
this.index = index;
this.assignedLabel = base.get(0).getAssignedLabel();
this.assignedLabel = getAssignedLabel(base.get(0));
Node lbo = base.get(0).getLastBuiltOn();
for (ExecutorChunk ec : executors) {
......@@ -193,6 +194,14 @@ public class MappingWorksheet {
lastBuiltOn = null;
}
private Label getAssignedLabel(SubTask task) {
for (LabelAssignmentAction laa : item.getActions(LabelAssignmentAction.class)) {
Label l = laa.getAssignedLabel(task);
if (l!=null) return l;
}
return task.getAssignedLabel();
}
public List<ExecutorChunk> applicableExecutorChunks() {
List<ExecutorChunk> r = new ArrayList<ExecutorChunk>(executors.size());
for (ExecutorChunk e : executors) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册