-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Shortlog strip console notes #4905
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
Shortlog strip console notes #4905
Conversation
…he middle of it. Generalize finding pre/postamble
…l output as well. Test sample script output.
…ly the relevant lines get processed
|
I imagine there is already something in Jira for this. Seems that the problem could be fixed with a much less intrusive patch solely to the log truncation logic: only truncate at a line boundary (after |
|
Or, the log truncation logic (in |
I thought maybe there was a reason it hasn't been implemented like this in the first place. This would change the actual "contract" from
I haven't gone this way because I thought the possibility of this functionality unnecessarily kicking-in would be relatively high taking into account that I think the |
Simple laziness AFAIK.
Fine from my PoV. The 150Kb is just a rough cutoff.
Not sure I am following.
I think it would be preferable to only display a complete initial line, even if there are no notes or any other ANSI escapes anywhere near. |
CC @oleg-nenashev this might be a problem with that feature you recently told me about IIRC? |
|
OK, if I understand correctly this assignment shapes up to be:
I am waiting on @oleg-nenashev regarding the last comment before starting off. |
To explain, I have started experimenting with console log line linking/highlighting support (similar to GitHub code browser). This pull request is a kind of my spare-time self-education effort, and in the current state it is unlikely to be submitted as a PR anytime soon. So my work does not block this pull request. |
Yes, assuming this works out it seems like it would be the most straightforward solution. |
Keep tests in adjusted form.
…atic for really large logs
|
The implementation is done as suggested. |
oleg-nenashev
left a 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.
Should be a net improvement. I am not sure whether check for \n is enough to cover all use-cases, but it should work for the declared ConSole Note objects which include encoded data and hence should not include line breaks.
Resetting start to 0 is a problem only in edge cases
| int r; | ||
| do { | ||
| r = bufferedInputStream.read(); | ||
| start = (r == -1)? 0 : start + 1; |
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.
So it will print the entire log if we hit the end of the stream, which defeats purpose of offset for large logs. Should not be a problem for real use-cases, but we might want to retain original behavior.
| start = (r == -1)? 0 : start + 1; | |
| start = (r == -1)? 0 : offset + 1; |
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.
The code change is not clear to me. My idea was to advance the start position for each byte that is different than \n. What this change would do is re-set start to the value of offset + 1 multiple times - offset doesn't get updated anywhere. Can you please explain what you had in mind?
This immediately breaks 2 tests which I think are valid use cases.
This might happen if someone tries to write the log, starting in the middle of the last line. I can see the following possibilities:
I think options 1. and 2. are the worst and option 3. would be the best - my original approach would actually do just that but it's been viewed as "too intrusive" (not being snarky - maybe it was). |
|
Option 3 is likely to be an overkill. FTR I can live with Option 4. Since there is no negative feedback, let's go ahead We may merge it in 24 hours if there is no negative feedback. Please see the merge process documentation for more information about the merge process |
| @Test | ||
| public void wontPushOffsetOnRenderingFromBeginning() throws Exception { | ||
| assertWriteLogToEquals(new String(new char[5]).replace("\0", SAMPLE_BUILD_OUTPUT) + "Finished: SUCCESS.\n", 0); | ||
| } |
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.
Note that
@Test
public void wontPushOffsetOnRenderingFromBeginningOfLine() throws Exception {
assertWriteLogToEquals(new String(new char[3]).replace("\0", SAMPLE_BUILD_OUTPUT) + "Finished: SUCCESS.\n", 2 * SAMPLE_BUILD_OUTPUT.length());
}fails: it prints 2 copies, not 3 like you might expect. This is because of a “fencepost error”: when the offset happens to point to the beginning of a line (just not the first line), that line is skipped.
If this method with offset > 0 is only being used to skip 150Kb of text or whatever, the bug would hardly be noticeable.
| getLogText().writeHtmlTo(offset, out.asWriter()); | ||
| long start = offset; | ||
| if (offset > 0) { | ||
| try (BufferedInputStream bufferedInputStream = new BufferedInputStream(getLogInputStream())) { |
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.
This is a serious performance regression for Pipeline as discovered in #10515: as of jenkinsci/workflow-job-plugin#27 this method is not intended to scale well (jenkinsci/workflow-job-plugin#27 (comment)).
No JIRA ticket exists.
While rendering log output for a large logfile Jenkins skips the beginning and shows the last
150KBof data. It is possible that the beginning of such a shortlog falls in the middle of a serializedConsoleNoteand then part of a Gziped and base64-encoded string gets rendered in the output.This may lead to suspicions that something in the build went wrong and/or that Jenkins or one of its plugins did something wrong. In fact there is a pretty old issue in ansicolor-plugin suspecting just that.
This PR takes care of this by:
preBuffer) used to detect if shortlog begin falls in the middle of a serializedConsoleNoteConsoleNotePlease let me know if you would prefer to have a full-blown JIRA ticket (the change is not that big) - I will be happy to create it if you think the issue is worth it.
Proposed changelog entries
ConsoleNotein truncated log output.Proposed upgrade guidelines
N/A
Submitter checklist
Proposed changelog entriessection only if there are breaking changes or other changes which may require extra steps from users during the upgradeMaintainer checklist
Before the changes are marked as
ready-for-merge:Proposed changelog entriesare correctupgrade-guide-neededlabel is set and there is aProposed upgrade guidelinessection in the PR title. (example)lts-candidateto be considered (see query).