提交 25084f52 编写于 作者: K Kohsuke Kawaguchi

[FIXED JENKINS-3265]

Made the in-flight build survive the reload from the disk.
上级 a32f2dd3
......@@ -62,6 +62,9 @@ Upcoming changes</a>
<li class=bug>
an in-progress build was dropped from JSON API when lazy-loading was introduced.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-15583">issue 15583</a>)
<li class=bug>
In-progress builds now survive the "reload from disk" administrator action.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-3265">issue 3265</a>)
<li class=bug>
Fixed a bad interaction between Windows symlinks and build record lazy loading.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-15587">issue 15587</a>)
......
......@@ -282,9 +282,20 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
super.onLoad(parent, name);
RunMap<R> builds = createBuildRunMap();
if (this.builds!=null) {
RunMap<R> currentBuilds = this.builds;
if (currentBuilds==null) {
// are we overwriting what currently exist?
// this is primarily when Jenkins is getting reloaded
Item current = parent.getItem(name);
if (current!=null && current.getClass()==getClass()) {
currentBuilds = ((AbstractProject)current).builds;
}
}
if (currentBuilds !=null) {
// if we are reloading, keep all those that are still building intact
for (R r : this.builds.getLoadedBuilds().values()) {
for (R r : currentBuilds.getLoadedBuilds().values()) {
if (r.isBuilding())
builds.put(r);
}
......
......@@ -2505,6 +2505,8 @@ public class Jenkins extends AbstractCIBase implements ModifiableTopLevelItemGro
}
});
final Set<String> loadedNames = Collections.synchronizedSet(new HashSet<String>());
TaskGraphBuilder g = new TaskGraphBuilder();
Handle loadHudson = g.requires(EXTENSIONS_AUGMENTED).attains(JOB_LOADED).add("Loading global config", new Executable() {
public void run(Reactor session) throws Exception {
......@@ -2527,7 +2529,6 @@ public class Jenkins extends AbstractCIBase implements ModifiableTopLevelItemGro
if (slaves == null) slaves = new NodeList();
clouds.setOwner(Jenkins.this);
items.clear();
// JENKINS-8043: re-add the slaves which were not saved into the config file
// and are now missing, but still connected.
......@@ -2550,10 +2551,26 @@ public class Jenkins extends AbstractCIBase implements ModifiableTopLevelItemGro
public void run(Reactor session) throws Exception {
TopLevelItem item = (TopLevelItem) Items.load(Jenkins.this, subdir);
items.put(item.getName(), item);
loadedNames.add(item.getName());
}
});
}
g.requires(JOB_LOADED).add("Cleaning up old builds",new Executable() {
public void run(Reactor reactor) throws Exception {
// anything we didn't load from disk, throw them away.
// doing this after loading from disk allows newly loaded items
// to inspect what already existed in memory (in case of reloading)
// retainAll doesn't work well because of CopyOnWriteMap implementation, so remove one by one
// hopefully there shouldn't be too many of them.
for (String name : items.keySet()) {
if (!loadedNames.contains(name))
items.remove(name);
}
}
});
g.requires(JOB_LOADED).add("Finalizing set up",new Executable() {
public void run(Reactor session) throws Exception {
rebuildDependencyGraph();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册