提交 7335533d 编写于 作者: K kohsuke

[FIXED HUDSON-4873] in 1.336

    Matrix configuration builds should continue even when Hudson is about to shut down.
    (<a href="https://hudson.dev.java.net/issues/show_bug.cgi?id=4873">issue 4873</a>)


git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@23980 71c3de6d-444a-0410-be80-ed276b4c234a
上级 686d1b92
......@@ -37,6 +37,7 @@ import hudson.model.Label;
import hudson.model.ParametersAction;
import hudson.model.Project;
import hudson.model.SCMedItem;
import hudson.model.Queue.NonBlockingTask;
import hudson.model.Cause.LegacyCodeCause;
import hudson.scm.SCM;
import hudson.tasks.BuildWrapper;
......@@ -53,7 +54,7 @@ import java.util.Map;
*
* @author Kohsuke Kawaguchi
*/
public class MatrixConfiguration extends Project<MatrixConfiguration,MatrixRun> implements SCMedItem {
public class MatrixConfiguration extends Project<MatrixConfiguration,MatrixRun> implements SCMedItem, NonBlockingTask {
/**
* The actual value combination.
*/
......
......@@ -27,8 +27,10 @@ import hudson.model.Node.Mode;
import hudson.model.Queue.ApplicableJobOfferList;
import hudson.model.Queue.JobOffer;
import hudson.model.Queue.Task;
import hudson.model.Queue.NonBlockingTask;
import hudson.util.ConsistentHash;
import hudson.util.ConsistentHash.Hash;
import hudson.matrix.MatrixConfiguration;
import java.util.logging.Logger;
......@@ -156,7 +158,7 @@ public abstract class LoadBalancer /*implements ExtensionPoint*/ {
return new LoadBalancer() {
@Override
protected JobOffer choose(Task task, ApplicableJobOfferList applicable) {
if (Hudson.getInstance().isQuietingDown()) {
if (Hudson.getInstance().isQuietingDown() && !(task instanceof NonBlockingTask)) {
// if we are quieting down, don't start anything new so that
// all executors will be eventually free.
return null;
......
......@@ -28,6 +28,7 @@ import hudson.ExtensionList;
import hudson.ExtensionPoint;
import hudson.Util;
import hudson.XmlFile;
import hudson.matrix.MatrixConfiguration;
import hudson.cli.declarative.CLIMethod;
import hudson.cli.declarative.CLIResolver;
import hudson.remoting.AsyncFutureImpl;
......@@ -928,6 +929,14 @@ public class Queue extends ResourceController implements Saveable {
*/
public interface FlyweightTask extends Task {}
/**
* Marks {@link Task}s that are not affected by the {@linkplain Hudson#isQuietingDown()} quietting down},
* because these tasks keep other tasks executing.
*
* @since 1.336
*/
public interface NonBlockingTask extends Task {}
/**
* Task whose execution is controlled by the queue.
*
......@@ -1365,7 +1374,7 @@ public class Queue extends ResourceController implements Saveable {
public CauseOfBlockage getCauseOfBlockage() {
Hudson hudson = Hudson.getInstance();
if(hudson.isQuietingDown())
if(hudson.isQuietingDown() && !(task instanceof NonBlockingTask))
return CauseOfBlockage.fromMessage(Messages._Queue_HudsonIsAboutToShutDown());
Label label = task.getAssignedLabel();
......
......@@ -41,6 +41,15 @@ import org.jvnet.hudson.test.SingleFileSCM
import org.jvnet.hudson.test.UnstableBuilder
import com.gargoylesoftware.htmlunit.html.HtmlTable
import org.jvnet.hudson.test.Bug
import org.jvnet.hudson.test.TestBuilder
import hudson.model.AbstractBuild
import hudson.Launcher
import hudson.model.BuildListener
import hudson.util.OneShotEvent
import java.util.concurrent.Future
import java.util.concurrent.TimeUnit
import hudson.model.FreeStyleProject
import java.util.concurrent.TimeoutException
/**
*
......@@ -184,4 +193,41 @@ public class MatrixProjectTest extends HudsonTestCase {
);
assertRectangleTable(p)
}
/**
* Quiettng down Hudson causes a dead lock if the parent is running but children is in the queue
*/
@Bug(4873)
void testQuietDownDeadlock() {
def p = createMatrixProject();
p.axes = new AxisList(new Axis("foo","1","2"));
p.runSequentially = true; // so that we can put the 2nd one in the queue
OneShotEvent firstStarted = new OneShotEvent();
OneShotEvent buildCanProceed = new OneShotEvent();
p.getBuildersList().add( [perform:{ AbstractBuild build, Launcher launcher, BuildListener listener ->
firstStarted.signal();
buildCanProceed.block();
return true;
}] as TestBuilder );
Future f = p.scheduleBuild2(0)
// have foo=1 block to make sure the 2nd configuration is in the queue
firstStarted.block();
// enter into the quiet down while foo=2 is still in the queue
hudson.doQuietDown();
buildCanProceed.signal();
// make sure foo=2 still completes. use time out to avoid hang
assertBuildStatusSuccess(f.get(10,TimeUnit.SECONDS));
// MatrixProject scheduled after the quiet down shouldn't start
try {
p.scheduleBuild2(0).get(3,TimeUnit.SECONDS)
fail()
} catch (TimeoutException e) {
// expected
}
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册