-
-
Notifications
You must be signed in to change notification settings - Fork 9k
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
Adjusted TaskListener flushing in remote code #3703
Conversation
@@ -169,7 +169,7 @@ private void writeObject(ObjectOutputStream out) throws IOException { | |||
} | |||
|
|||
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { | |||
out = new PrintStream((OutputStream)in.readObject(),true); | |||
out = new PrintStream((OutputStream)in.readObject(), false); |
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.
We expect that code flushes a stream when it is done with it
That expectation seems reasonable and preferable to the current behavior, but given that this code has been unmodified since 2007 I am a little concerned that this may break things. Should be easy enough to fix if it does cause issues, but I do not have a good sense of whether there may be widespread impact.
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.
given that this code has been unmodified since 2007 I am a little concerned that this may break things
Indeed. Of course that is true of a lot of Jenkins code.
I want to do some testing of this and sleep on a bit more before pushing into releases. |
…otator had neglected to implement flush properly.
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.
Latest changes look good to me. Do you plan to add any tests here, or just do some manual testing of various affected scenarios?
TBD.
Have done some sanity checks so far, but deserves more. |
Note to self: need to document expected caller usage of remoted |
…enkinsci/workflow-job-plugin#113 I cannot seem to remember to do it.
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.
LGTM
This just turned into a grab bag of JEP-210-related patches which would be better refiled separately. |
Amends #3563 a bit. See discussion in jenkinsci/workflow-api-plugin#81. There are several changes here:
StreamTaskListener
created on the master does not set thePrintStream.autoFlush
flag. So why would we do so on the remote side? That merely produces a flurry ofProxyOutputStream.Flush
packets. We expect that code flushes a stream when it is done with it. In fact from 2.121.x → 2.138.x for freestyle builds runningShell
I see introduced flush packets, from [JENKINS-52729] Launcher.ProcStarter.stdout(TaskListener) discards remotability #3563 I presume, which this PR corrects again.RemoteLaunchCallable
on the agent side produces aLocalLauncher
which produces aLocalProc
which usesStreamCopyThread
to forward stdout/stderr of the process. Yet as far as I can tell, this never flushed its sink unless you pass thecloseOut
flag (which no code in core does), meaning the tail end of log output could be lost if the sink were buffered. Freestyle builds have unbuffered logs, so probably this never mattered, but for JEP-210 I am finding that some buffering for Pipeline with local log storage is useful for performance reasons, and definitely for cloud log storage it is expected.Launcher
is not used in this way for durable tasks likesh
, but variousSynchronousNonBlockingStepExecution
s (and thus alsoSimpleBuildStep
s) use it.LineTransformationOutputStream
to handleflush
properly. Otherwise a flush on top of a stack of decorated loggers can get lost.ConsoleNote
Javadoc related to JEP-210.Proposed changelog entries
LineTransformationOutputStream.Delegating
.