[JEP-210] Log handling rewrite#27
Conversation
| if (executor != null) { | ||
| AsynchronousExecution asynchronousExecution = executor.getAsynchronousExecution(); | ||
| if (asynchronousExecution != null) { | ||
| asynchronousExecution.completed(null); |
There was a problem hiding this comment.
Uses to be part of copyLogsTask (line 278); that is now gone, so we need to somehow release the flyweight executor slot. This seems like the appropriate place to do it.
pom.xml
Outdated
| </pluginRepositories> | ||
| <properties> | ||
| <jenkins.version>1.642.3</jenkins.version> | ||
| <hpi-plugin.version>1.120</hpi-plugin.version> |
There was a problem hiding this comment.
Ideally should be updated in the Parent POM
| } | ||
| try { | ||
| onStartBuilding(); | ||
| // TODO introduce API to wrap out log location |
There was a problem hiding this comment.
Implementation from the prototype: https://github.com/oleg-nenashev/workflow-job-plugin/tree/jw-hackaton-external-logging
There was a problem hiding this comment.
Saw that, but it is not going to work.
| return TaskListener.NULL; | ||
| } | ||
| } | ||
| @Override public InputStream getLog() throws IOException { |
There was a problem hiding this comment.
Maybe Stream is not a perfect solution for Logging. I would rather go after an event-based model similar to JUL, but it will require more changes (it's in my design btw)
There was a problem hiding this comment.
Tons of Jenkins APIs expect a TaskListener or OutputStream for output, and expect an AnnotatedLargeText or InputStream for input, so streams are mandated at some level I think. Of course a logging implementation might internally work with lines.
| * Prefix used in metadata lines. | ||
| */ | ||
| public static final String CONSOLE_NOTE_PREFIX = "[Pipeline] "; | ||
| private static final String CONSOLE_NOTE_PREFIX = "[Pipeline] "; |
There was a problem hiding this comment.
🐜 binary compat change without a real need
There was a problem hiding this comment.
Just minimizing access of things which were never really supposed to be public.
…e for getLogFile().
…y encompassing all of the functionality of jenkinsci#21.
| synchronized (this) { | ||
| PipelineIOUtils.writeByXStream(this, loc, XSTREAM2, isAtomic); | ||
| SaveableListener.fireOnChange(this, file); | ||
| if (Boolean.TRUE.equals(completed)) { |
There was a problem hiding this comment.
@jglick No! 🐛 🐛 🐛 and a whole nest of 🐛s. This is not the right place to be terminating the AsynchronousExecution - if an IOException never occurs, the build never finishes.
You're welcome to do an extra on-save check somewhere logical -- because we have had hard-to-trace issues with the build not getting killed before, but this makes undead Pipelines more likely.
There was a problem hiding this comment.
There is explanation elsewhere of why we have to do the termination here. I can think about whether it is possible to do so more forcefully, such as in a finally block.
There was a problem hiding this comment.
if an IOException never occurs
I suppose you mean if an IOException does occur.
the build never finishes
As noted in a separate thread, even if no subsequent call to save is ever made, it is misleading to say that the build is “not finished”. Rather, there would be a stale AsynchronousExecution, which likely has little or no visible impact.
There was a problem hiding this comment.
A stale AsynchronousExecution translates to essentially a "zombie" job that proves highly irritating to users -- it seems like it never completes even if the build is marked as done. Also it holds onto the OneShotExecutor indefinitely.
There was a problem hiding this comment.
Again the AsynchronousExecution normally has no visible effect on anything—it only appears while we are actively running Groovy code, which of course we are not if the build is completed.
And again if some problem in existing code (whether in workflow-job or workflow-cps) results in a condition whereby <completed>true</completed> never gets written to build.xml, the AsynchronousExecution is the least of your concerns, since after the next restart onLoad will be confused. Possibly #93 will defend against that case—figure out that completed is wrong and save the correction—but at that point any old Executors are no longer an issue anyway (and there should be no new AfterRestartTask).
There was a problem hiding this comment.
I think the after-restart case should have been fixed by #104.
svanoort
left a comment
There was a problem hiding this comment.
I've done my best to give this at least a decent readthrough (though I don't imagine every bug has been caught). There are a couple bugs that need fixing but in general the implementation is pretty sane.
Or as sane as Pipeline internals are going to be anyway, given some of the Lovecraftian back-compatibility horrors they're dragging along with them... (ia ia FlowGraph f'htagn!) 🐙
svanoort
left a comment
There was a problem hiding this comment.
The handling of AsynchronousExecutions here is wrong and will probably break in the face of some fairly common cases (IOExceptions, etc). But that's not going to cause Critical/Blocker issues for users, just annoying ones. So, I'm removing my "changes requested" and this can go forward without my approval (I don't feel right "approving" something which I see actual bugs in).
The more critical risks here are the problems we can't anticipate, anyway.
…Also reduce scope of lock.
src/main/java/org/jenkinsci/plugins/workflow/job/console/NewNodeConsoleNote.java
Show resolved
Hide resolved
svanoort
left a comment
There was a problem hiding this comment.
This still does not feel like the correct place to mark the AsynchronousExecution completed, but it seems to work as far as I can tell from cross-testing, whereas for reasons I'm still at a loss to explain, the correct place to mark it generates test flakes (primarily in CI) -- see #108 -- so I say we roll with this and release it -- with appropriate cautions that the log handling rewrite is a more-than-normal risk for people updating.
Also unclear to me why. I note that the last build of this PR not only passed, but acc. to the log had no flakes. Anyway, this is something that could be sorted out later—there is no API or settings impact. |
Downstream of jenkinsci/workflow-api-plugin#17 and jenkinsci/workflow-support-plugin#15. Cf. #21.
JEP-210
ConsoleNoteon every lineoptimizePipelineLargeText.<init>optimizeWorkflowRun.getLogInputStreamNice-to-have things I am deferring:
parallelbranch by default