Skip to content

Commit

Permalink
[JENKINS-70622] Do not clean temporary files on agents (#24)
Browse files Browse the repository at this point in the history
#11 was merged 5 years
ago but only released in 1.15 Feb 2023.  That change included a cleanup
step that removes specifically named files from the /tmp folder using
a Linux specific find command.  There is not enough benefit from that
cleanup step to justify the loss of portability to other Unix systems
like FreeBSD, OpenBSD, macOS, and Solaris.

https://issues.jenkins.io/browse/JENKINS-70622 reported the issue on
Solaris, AIX, and HP variants of Unix.
  • Loading branch information
MarkEWaite authored Feb 16, 2023
1 parent cf9a3a4 commit 3596404
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 38 deletions.
36 changes: 0 additions & 36 deletions src/main/java/org/jenkinsci/plugins/slave_setup/Components.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import java.util.List;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.SystemUtils;

import hudson.AbortException;
import hudson.EnvVars;
Expand Down Expand Up @@ -249,7 +248,6 @@ public static boolean doConfigSetups(List<Computer> activeSlaves) {
try {
Components manager = new Components(slave);
manager.doConfig();
manager.clearTemporally();
} catch (Exception ex) {
Components.info(String.format("Failed to configure %s%nErr:%s", slave.getName(), ex.getMessage()));
succeded = false;
Expand All @@ -275,7 +273,6 @@ public static boolean doSetups(List<Computer> activeSlaves) {
try {
Components manager = new Components(slave);
manager.doSetup();
manager.clearTemporally();
} catch (Exception ex) {
Components.info(String.format("Failed to configure %s%nErr:%s", slave.getName(), ex.getMessage()));
succeded = false;
Expand Down Expand Up @@ -316,39 +313,6 @@ private void doDeploy(SetupConfigItem installInfo) throws IOException, Interrupt
this.addCache(installInfo.remoteCache());
}

/**
* Only works on Unix Operating Systems, this will use some unix commands to
* clear temporally data
*
* If file has more than 5 minutes in the last modified tag, it will be removed.
* Only will remove files which name is jenkins
*
* This function require at least (find) binary to be installed
*
* @throws InterruptedException Broken pipe.
* @throws IOException IO error accessing remotePath
* @throws AbortException User close/Cancelled
*
*/
public void clearTemporally() throws AbortException, IOException, InterruptedException {

String clearTmp = "find /tmp -type f -atime +10 -delete -iname *jenkins*.sh -maxdepth 0";
EnvVars environ = SetupDeployer.createEnvVarsForComputer(this.slave);

if (this.remotePath.getRemote().startsWith("/")) {
// Clear slave temporally data
Components.info("Clearing temporally data on " + this.slave.getName());
validateResponse(Utils.multiOsExecutor(Components.listener, clearTmp, this.remotePath, environ));
}

if (SystemUtils.IS_OS_UNIX) {
// Clear master temporally data
Components.info("Clearing temporally data on jenkins master");
validateResponse(SetupDeployer.executeScriptOnMaster(Components.listener, clearTmp, environ));
}
Components.debug("Finished temporal data removed");
}

/**
* Validate execution scripts code, in order to throw exception if not
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ public void preOnline(Computer c, Channel channel, FilePath root, TaskListener l

manager.doSetup();
Components.debug("Setup Ended");

manager.clearTemporally();
}

}

0 comments on commit 3596404

Please sign in to comment.