Skip to content
Permalink
Browse files
Merge branch 'master' into JENKINS-27289
  • Loading branch information
liorhson committed May 6, 2015
2 parents e166c92 + bcb86d9 commit a503b66977e3058cdd54f1701c248cc864d9e36c
@@ -65,6 +65,10 @@
</div><!--=TRUNK-END=-->
<h3><a name=v1.612>What's new in 1.612</a> (2015/05/03)</h3>
<ul class=image>
<li class=rfe>
<strong>Jenkins now requires Java 7</strong>.
(<a href="http://jenkins-ci.org/content/good-bye-java6">announcement</a>,
<a href="https://issues.jenkins-ci.org/browse/JENKINS-28120">issue 28120</a>)
<li class=bug>
Handle AbortException publisher status in the same way as deprecated false boolean status
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-26964">issue 26964</a>)
@@ -77,10 +81,6 @@ <h3><a name=v1.612>What's new in 1.612</a> (2015/05/03)</h3>
<li class=rfe>
Larger minimum popup menu height.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-27067">issue 27067</a>)
<li class=rfe>
As <a href="http://jenkins-ci.org/content/good-bye-java6">promised</a>, shipping
with Java7 class files.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-28120">issue 28120</a>)
<li class=bug>
<code>Descriptor.getId</code> fix in 1.610 introduced regressions affecting at least the Performance and NodeJS plugins.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-28093">issue 28093</a> and <a href="https://issues.jenkins-ci.org/browse/JENKINS-28110">issue 28110</a>)
@@ -271,14 +271,25 @@ public void addAction(Action a) {
/**
* This is where the log from the remote agent goes.
* The method also creates a log directory if required.
* @see #relocateOldLogs()
* @see #getLogDir(), #relocateOldLogs()
*/
public File getLogFile() {
public @Nonnull File getLogFile() {
return new File(getLogDir(),"slave.log");
}

/**
* Directory where rotated slave logs are stored.
*
* The method also creates a log directory if required.
*
* @since 1.613
*/
protected @Nonnull File getLogDir() {
File dir = new File(Jenkins.getInstance().getRootDir(),"logs/slaves/"+nodeName);
if (!dir.exists() && !dir.mkdirs()) {
LOGGER.severe("Failed to create slave log directory " + dir.getAbsolutePath());
}
return new File(dir,"slave.log");
return dir;
}

/**
@@ -655,6 +655,12 @@ protected void kill() {
super.kill();
closeChannel();
IOUtils.closeQuietly(log);

try {
Util.deleteRecursive(getLogDir());
} catch (IOException ex) {
logger.log(Level.WARNING, "Unable to delete slave logs", ex);
}
}

public RetentionStrategy getRetentionStrategy() {
@@ -0,0 +1,55 @@
/*
* The MIT License
*
* Copyright (c) 2015 Red Hat, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package hudson.model;

import static org.junit.Assert.*;

import java.io.File;

import jenkins.model.Jenkins;
import hudson.slaves.DumbSlave;

import org.junit.Rule;
import org.junit.Test;
import org.jvnet.hudson.test.JenkinsRule;

public class ComputerTest {

@Rule public JenkinsRule j = new JenkinsRule();

@Test
public void discardLogsAfterDeletion() throws Exception {
DumbSlave delete = j.createOnlineSlave(Jenkins.getInstance().getLabelAtom("delete"));
DumbSlave keep = j.createOnlineSlave(Jenkins.getInstance().getLabelAtom("keep"));
File logFile = delete.toComputer().getLogFile();
assertTrue(logFile.exists());

Jenkins.getInstance().removeNode(delete);

assertFalse("Slave log should be deleted", logFile.exists());
assertFalse("Slave log directory should be deleted", logFile.getParentFile().exists());

assertTrue("Slave log should be kept", keep.toComputer().getLogFile().exists());
}
}

0 comments on commit a503b66

Please sign in to comment.