Merge "ignore non-deterministic build failure and log it."
This commit is contained in:
commit
84a20df823
|
@ -19,9 +19,9 @@
|
||||||
package hudson.plugins.gearman;
|
package hudson.plugins.gearman;
|
||||||
|
|
||||||
import hudson.model.AbstractProject;
|
import hudson.model.AbstractProject;
|
||||||
|
import hudson.model.Computer;
|
||||||
import hudson.model.Label;
|
import hudson.model.Label;
|
||||||
import hudson.model.Node;
|
import hudson.model.Node;
|
||||||
import hudson.model.Computer;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
@ -32,7 +32,6 @@ import java.util.Set;
|
||||||
import jenkins.model.Jenkins;
|
import jenkins.model.Jenkins;
|
||||||
|
|
||||||
import org.gearman.worker.GearmanFunctionFactory;
|
import org.gearman.worker.GearmanFunctionFactory;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -63,6 +62,7 @@ public class ExecutorWorkerThread extends AbstractWorkerThread{
|
||||||
this.masterName = masterName;
|
this.masterName = masterName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void initWorker() {
|
protected void initWorker() {
|
||||||
availability.unlock(worker);
|
availability.unlock(worker);
|
||||||
super.initWorker();
|
super.initWorker();
|
||||||
|
@ -147,7 +147,11 @@ public class ExecutorWorkerThread extends AbstractWorkerThread{
|
||||||
public void registerJobs() {
|
public void registerJobs() {
|
||||||
HashMap<String,GearmanFunctionFactory> newFunctionMap = new HashMap<String,GearmanFunctionFactory>();
|
HashMap<String,GearmanFunctionFactory> newFunctionMap = new HashMap<String,GearmanFunctionFactory>();
|
||||||
|
|
||||||
if (!this.node.toComputer().isOffline()) {
|
try {
|
||||||
|
Node n = getNode();
|
||||||
|
Computer c = n.toComputer();
|
||||||
|
|
||||||
|
if (!c.isOffline()) {
|
||||||
List<AbstractProject> allProjects = Jenkins.getInstance().getAllItems(AbstractProject.class);
|
List<AbstractProject> allProjects = Jenkins.getInstance().getAllItems(AbstractProject.class);
|
||||||
for (AbstractProject<?, ?> project : allProjects) {
|
for (AbstractProject<?, ?> project : allProjects) {
|
||||||
|
|
||||||
|
@ -163,7 +167,7 @@ public class ExecutorWorkerThread extends AbstractWorkerThread{
|
||||||
String jobFunctionName = "build:" + projectName;
|
String jobFunctionName = "build:" + projectName;
|
||||||
newFunctionMap.put(jobFunctionName, new CustomGearmanFunctionFactory(
|
newFunctionMap.put(jobFunctionName, new CustomGearmanFunctionFactory(
|
||||||
jobFunctionName, StartJobWorker.class.getName(),
|
jobFunctionName, StartJobWorker.class.getName(),
|
||||||
project, this.node, this.masterName, worker));
|
project, n, this.masterName, worker));
|
||||||
} else { // register "build:$projectName:$projectLabel" if this
|
} else { // register "build:$projectName:$projectLabel" if this
|
||||||
// node matches a node from the project label
|
// node matches a node from the project label
|
||||||
|
|
||||||
|
@ -174,18 +178,18 @@ public class ExecutorWorkerThread extends AbstractWorkerThread{
|
||||||
|
|
||||||
// iterate thru all project labels and find matching nodes
|
// iterate thru all project labels and find matching nodes
|
||||||
for (String projectLabel : projectLabels) {
|
for (String projectLabel : projectLabels) {
|
||||||
if (projectLabelNodes.contains(this.node)) {
|
if (projectLabelNodes.contains(n)) {
|
||||||
String jobFunctionName = "build:" + projectName
|
String jobFunctionName = "build:" + projectName
|
||||||
+ ":" + projectLabel;
|
+ ":" + projectLabel;
|
||||||
// register with label (i.e. "build:$projectName:$projectLabel")
|
// register with label (i.e. "build:$projectName:$projectLabel")
|
||||||
newFunctionMap.put(jobFunctionName, new CustomGearmanFunctionFactory(
|
newFunctionMap.put(jobFunctionName, new CustomGearmanFunctionFactory(
|
||||||
jobFunctionName, StartJobWorker.class.getName(),
|
jobFunctionName, StartJobWorker.class.getName(),
|
||||||
project, this.node, this.masterName, worker));
|
project, n, this.masterName, worker));
|
||||||
jobFunctionName = "build:" + projectName;
|
jobFunctionName = "build:" + projectName;
|
||||||
// also register without label (i.e. "build:$projectName")
|
// also register without label (i.e. "build:$projectName")
|
||||||
newFunctionMap.put(jobFunctionName, new CustomGearmanFunctionFactory(
|
newFunctionMap.put(jobFunctionName, new CustomGearmanFunctionFactory(
|
||||||
jobFunctionName, StartJobWorker.class.getName(),
|
jobFunctionName, StartJobWorker.class.getName(),
|
||||||
project, this.node, this.masterName, worker));
|
project, n, this.masterName, worker));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -196,6 +200,9 @@ public class ExecutorWorkerThread extends AbstractWorkerThread{
|
||||||
Set<GearmanFunctionFactory> functionSet = new HashSet<GearmanFunctionFactory>(functionMap.values());
|
Set<GearmanFunctionFactory> functionSet = new HashSet<GearmanFunctionFactory>(functionMap.values());
|
||||||
updateJobs(functionSet);
|
updateJobs(functionSet);
|
||||||
}
|
}
|
||||||
|
} catch (NullPointerException npe) {
|
||||||
|
logger.warn("Failed to register jobs on worker thread: "+getName()+" with worker: "+worker.getWorkerID(), npe);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized Node getNode() {
|
public synchronized Node getNode() {
|
||||||
|
|
Loading…
Reference in New Issue