Skip to content
Permalink
Browse files
[FIXED JENKINS-8408]
If slaves are late to come online after a Jenkins startup, we will see a huge spike of builds as Jenkins attempt to get a workspace for polling.
  • Loading branch information
kohsuke committed Oct 26, 2013
1 parent 41ce6c5 commit 28737ee9d1ae4ab02d650a284ec52e98e50d9f63
@@ -55,6 +55,9 @@
<!-- Record your changes in the trunk here. -->
<div id="trunk" style="display:none"><!--=TRUNK-BEGIN=-->
<ul class=image>
<li class=bug>

This comment has been minimized.

Copy link
@jglick
Do not polling
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-8408">issue 8408</a>)
<li class=bug>
Fixed the handling of nested variable expansion.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-20280">issue 20280</a>)
@@ -81,11 +81,13 @@
import hudson.util.AlternativeUiTextProvider.Message;
import hudson.util.DescribableList;
import hudson.util.FormValidation;
import hudson.util.TimeUnit2;
import hudson.widgets.BuildHistoryWidget;
import hudson.widgets.HistoryWidget;
import jenkins.model.Jenkins;
import jenkins.model.JenkinsLocationConfiguration;
import jenkins.model.ModelObjectWithChildren;
import jenkins.model.Uptime;
import jenkins.model.lazy.AbstractLazyLoadRunMap.Direction;
import jenkins.scm.DefaultSCMCheckoutStrategyImpl;
import jenkins.scm.SCMCheckoutStrategy;
@@ -1532,7 +1534,19 @@ private PollingResult _poll(TaskListener listener, SCM scm) throws IOException,
}
}

// build now, or nothing will ever be built
// At this point we start thinking about triggering a build just to get a workspace,
// because otherwise there's no way we can detect changes.
// However, first there are some conditions in which we do not want to do so.

// give time for slaves to come online if we are right after reconnection (JENKINS-8408)
long running = Jenkins.getInstance().getInjector().getInstance(Uptime.class).getUptime();
long remaining = TimeUnit2.MINUTES.toMillis(10)-running;
if (remaining>0) {
listener.getLogger().print(Messages.AbstractProject_AwaitingWorkspaceToComeOnline(remaining/1000));
listener.getLogger().println( " (" + workspaceOfflineReason.name() + ")");
return NO_CHANGES;
}

Label label = getAssignedLabel();
if (label != null && label.isSelfLabel()) {
// if the build is fixed on a node, then attempting a build will do us
@@ -1541,17 +1555,19 @@ private PollingResult _poll(TaskListener listener, SCM scm) throws IOException,
listener.getLogger().println( " (" + workspaceOfflineReason.name() + ")");
return NO_CHANGES;
}

listener.getLogger().println( ws==null
? Messages.AbstractProject_WorkspaceOffline()
: Messages.AbstractProject_NoWorkspace());
if (isInQueue()) {
listener.getLogger().println(Messages.AbstractProject_AwaitingBuildForWorkspace());
return NO_CHANGES;
} else {
listener.getLogger().print(Messages.AbstractProject_NewBuildForWorkspace());
listener.getLogger().println( " (" + workspaceOfflineReason.name() + ")");
return BUILD_NOW;
}

// build now, or nothing will ever be built
listener.getLogger().print(Messages.AbstractProject_NewBuildForWorkspace());
listener.getLogger().println( " (" + workspaceOfflineReason.name() + ")");
return BUILD_NOW;
} else {
WorkspaceList l = b.getBuiltOn().toComputer().getWorkspaceList();
return pollWithWorkspace(listener, scm, b, ws, l);
@@ -33,6 +33,7 @@ AbstractItem.Pronoun=Job
AbstractProject.AssignedLabelString_NoMatch_DidYouMean=There\u2019s no slave/cloud that matches this assignment. Did you mean \u2018{1}\u2019 instead of \u2018{0}\u2019?
AbstractProject.NewBuildForWorkspace=Scheduling a new build to get a workspace.
AbstractProject.AwaitingBuildForWorkspace=Awaiting build to get a workspace.
AbstractProject.AwaitingWorkspaceToComeOnline=We need to schedule a new build to get a workspace, but deferring {0}ms in the hope that one will become available soon
AbstractProject.Pronoun=Project
AbstractProject.Aborted=Aborted
AbstractProject.BuildInProgress=Build #{0} is already in progress{1}

2 comments on commit 28737ee

@schlamar

This comment has been minimized.

Copy link

@schlamar schlamar replied Nov 19, 2013

If I manually delete a workspace it will not be created anymore. I guess this is caused by this commit. Message is:

We need to schedule a new build to get a workspace, but deferring 414ms in the hope that one will become available soon (nonexisting_workspace)
Done. Took 0 ms
No changes
@jglick

This comment has been minimized.

Copy link
Member

@jglick jglick replied Nov 19, 2013

@schlamar if you have noticed a regression, please file it ASAP in JIRA with any relevant steps to reproduce, marked with the regression label, and have it be “blocking” JENKINS-8408.

Please sign in to comment.