[JENKINS-38313] - Introduce LogStorage API in the core#3575
[JENKINS-38313] - Introduce LogStorage API in the core#3575oleg-nenashev wants to merge 37 commits intojenkinsci:masterfrom
Conversation
…bmissions from Elasticsearch
Hide launcher complexity from plugin.
…-task-logging-poc # Conflicts: # core/src/main/java/hudson/model/AbstractProject.java # core/src/main/java/hudson/model/Job.java # core/src/main/java/hudson/model/Run.java
# Conflicts: # core/src/main/java/hudson/model/Job.java # core/src/main/java/hudson/model/Run.java
…sisted for Runs + extend API
…ation to External logging API
…er + documentation
|
Test failures are unrelated - UC issues |
|
@jenkinsci/cloud-native-sig I have addressed all comments in this change. Tests have been also added. IMO it is ready for review. |
carlossg
left a comment
There was a problem hiding this comment.
from my limited knowledge
There was a problem hiding this comment.
The main questions are about the relationship to jenkinsci/workflow-job-plugin#27 and specifically when and how the log storage is selected; see https://github.com/jenkinsci/workflow-api-plugin/pull/17/files#diff-1d162ef4f3f75e09c30e1f8e52e36b01R118.
|
|
||
| // Produce correct logger | ||
| // TODO: Consider merging with create Launcher | ||
| l = getLogStorage().decorateLauncher(l, getBuild(), currentNode, listener); |
| * @throws InterruptedException Was interrupted while decorating listeners | ||
| */ | ||
| @Nonnull | ||
| public Launcher decorateLauncher(@Nonnull Launcher original, |
There was a problem hiding this comment.
Remove. I cannot foresee any reason why we would ever need this, even with external sinks implemented via external processes—these should not be touching the user process being launched.
|
|
||
| /** | ||
| * Log storage associated with this build, if any. | ||
| * @since TODO |
There was a problem hiding this comment.
No need for @since on private stuff, only public APIs.
| } | ||
|
|
||
| if (logStorage == null) { | ||
| logStorage = new CompatFileLogStorage(this); |
There was a problem hiding this comment.
Rather keep it null and just return CompatFileLogStorage on demand so we do not touch the serial form unless you are actually using a nondefault implementation. Compare Run.getArtifactManager() vs. Run.artifactManager. You might need to introduce a pickLogStorage() correspondingly.
| /** | ||
| * Returns {@code true} if the log file is no longer being updated. | ||
| */ | ||
| public boolean isLoggingFinished(); |
There was a problem hiding this comment.
Consider isLoggingComplete (or isLoggingCompleted) by analogy with LargeText parameters?
| @ExportedBean | ||
| public abstract class LogStorage<T extends Loggable> { | ||
|
|
||
| protected transient T loggable; |
There was a problem hiding this comment.
Better to delete this and pass a T to any method which might need it. Make this an interface while you are at it.
| * @throws InterruptedException Operation was interrupted | ||
| */ | ||
| @Nonnull | ||
| public abstract AnnotatedLargeText<T> overallLog() throws IOException, InterruptedException; |
There was a problem hiding this comment.
Rename to getLogText for consistency with Run.
| @@ -1435,39 +1467,60 @@ public Collection<Fingerprint> getBuildFingerprints() { | |||
| return rawF; | |||
There was a problem hiding this comment.
Consider removing the historical gzip hacks and at best make this into a LogStorageFactory that detects log.gz existence for compatibility reasons (but never does this for new builds).
| * @since TODO | ||
| */ | ||
| @Restricted(Beta.class) | ||
| public class NoopLogStorage extends LogStorage { |
| * @since TODO | ||
| */ | ||
| @Restricted(Beta.class) | ||
| public abstract class StreamLogStorage extends LogStorage { |
There was a problem hiding this comment.
Maybe just delete it, since the hard parts are the read methods anyway; createBuildListener should become trivial.
jglick
left a comment
There was a problem hiding this comment.
A tip for killing StreamLogStorage.
|
|
||
| // Global log filter | ||
| for (ConsoleLogFilter filter : ConsoleLogFilter.all()) { | ||
| logger = filter.decorateLogger(build, logger); |
There was a problem hiding this comment.
Suggest moving this to a protected method in RunExecution…
| final Job<?, ?> project = build.getParent(); | ||
|
|
||
| // Project specific log filters | ||
| if (project instanceof BuildableItemWithBuildWrappers && build instanceof AbstractBuild) { |
There was a problem hiding this comment.
…and then override that in AbstractBuildExecution, cleaning this mistake up at last.
WorkflowRun does not yet support ConsoleLogFilter.all() but that can be dealt with separately: https://github.com/jenkinsci/workflow-job-plugin/pull/27/files#diff-68f690dbd3fa2d9fb89d6af3f8fd7216R218
| * @since 1.349 | ||
| */ | ||
| public @Nonnull InputStream getLogInputStream() throws IOException { | ||
| File logFile = getLogFile(); |
There was a problem hiding this comment.
For more current ideas about these methods, see overloads in WorkflowRun edited during jenkinsci/workflow-job-plugin#114 etc.
|
This was abandoned and does not need to be left open. |
Version of #3557, but with a single LogStorage as proposed by @jglick . The previous implementation had separate
LoggingMethodandLogBrowserimplementation directly in the core, but with this change I will need to move it to External Logging API.Proposed Changelog Entries
Submitter checklist
* Use the
Internal:prefix if the change has no user-visible impact (API, test frameworks, etc.)@carlossg @jenkinsci/code-reviewers I will appreciate feedback about the preferred approach