-
-
Notifications
You must be signed in to change notification settings - Fork 278
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[JENKINS-39370,JENKINS-39369] - Support of work directories in Remoting #129
[JENKINS-39370,JENKINS-39369] - Support of work directories in Remoting #129
Conversation
…ly create logs there if specified
|
||
if (slaveLog != null) { // Legacy behavior | ||
System.out.println("Using " + slaveLog + " as an agent Error log destination. 'Out' log won't be generated"); | ||
System.out.flush(); // Just in case the channel |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing words/sentence end in the comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep
if (!workDir.isDirectory()) { | ||
throw new IOException("The specified agent working directory path points to a non-directory file"); | ||
} | ||
if (!workDir.canWrite() || !workDir.canRead() || !workDir.canExecute()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should/couldn't it just (try to) create it? Like for .jenkins
will just be created if absent?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It creates it on-demand. This code is being executed only for existing files
System.setErr(new PrintStream(new TeeOutputStream(System.err, | ||
new FileOutputStream(new File(internalDirPath.toFile(), "remoting.err.log"))))); | ||
System.setOut(new PrintStream(new TeeOutputStream(System.out, | ||
new FileOutputStream(new File(internalDirPath.toFile(), "remoting.out.log"))))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering if this wouldn't be easier, for diagnostics purposes, to just output in a single file, and use JUL (I don't like it very much, but as it's already present in the JDK and Jenkins code already uses it in general...) or another logging API to distinguish between messages severities. E.g. here we don't have the dates of the logs, so it would make btw it hard or impossible to correlate .err logs to .out ones, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was considering it, but unfortunately SOME of executions on agents in plugin implementations write to STDOUT/STDERR instead of using JUL or whatever other logging. Hence we have to maintain such low-level API. Otherwise I would just implement JUL appender
…ting work directory
*/ | ||
public synchronized void startEngine() throws IOException { | ||
// Prepare the working directory if required | ||
final Path path = WorkDirManager.getInstance().initializeWorkDir(workDir.toFile(), internalDir, failIfWorkDirIsMissing); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally should be moved to /remoting/logs and logrotated
Tests pass for me locally. I have no idea how these changes cause such failure in the Channel property. And #132 works like a charm |
@reviewbybees would be useful |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks mostly ok, I think you can use the aliases
for slaveLog
and rename it now. I also wonder if you have missed passing slaveLog
through
* If specified, this option overrides the default destination within {@link #workDir}. | ||
* If both this options and {@link #workDir} is not set, the log will not be generated. | ||
*/ | ||
@Option(name="-slaveLog", usage="Local agent error log destination (overrides workDir)") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Option(name="-agentLog", aliases={"-slaveLog"}, ...
and be done with the rename
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was considering renaming.
My main concern about agent
is that we will have Jenkins agent
and remoting agent
terms. And they won't be equal in general.
jnlpArgs.add(internalDir); | ||
jnlpArgs.add("-failIfWorkDirIsMissing"); | ||
jnlpArgs.add(Boolean.toString(failIfWorkDirIsMissing)); | ||
} | ||
if (candidateCertificates != null && !candidateCertificates.isEmpty()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pass through slaveLog/AgentLog
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is https://issues.jenkins-ci.org/browse/JENKINS-39817 for it. I'm not a big fan of adding this option since we are going to have the workDir
now. But maybe it's good for the code consistency
* @throws IOException Verification failure | ||
*/ | ||
private static void verifyDirectory(@Nonnull File dir, @Nonnull DirType type, boolean failIfMissing) throws IOException { | ||
if (dir.exists()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I would expect the process to try to create the directory path if it is missing and complain if it can't create the directory.
|
||
/** | ||
* Sets up logging subsystem in the working directory. | ||
* It the logging system is already initialized, do nothing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If
@reviewbybees No additional reviews required right now. Will push the logrotate support soon as we have discussed with @stephenc |
JENKINS-18578 seems like the most critical change. |
@stephenc suggested doing it in the PR, so I decided to address it as a part of JENKINS-39370. But the code still has initialization in hudson.remoting.Launcher for other logging modes.
…in its interbal directory
@reviewbybees I am working on extra functional tests, but the core logic & documentation is ready to review |
This pull request originates from a CloudBees employee. At CloudBees, we require that all pull requests be reviewed by other CloudBees employees before we seek to have the change accepted. If you want to learn more about our process please see this explanation. |
…ogging.config.file system property
@reviewbybees Tests are also ready, so it can be reviewed. I will post the design doc by tomorrow. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes since my last revew LGTM
@reviewbybees done. I will do more testing in downstream PRs |
This pull requests adds a basic support of workspaces to Remoting. It offers options, which allow enabling workspaces for JNLP and SSH agents in Jenkins.
Scope of changes:
Potential improvements: