forked from ConsoleCatzirl/jenkins-logstash-plugin
-
Notifications
You must be signed in to change notification settings - Fork 109
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
avoid duplicate sending and global notifier mode #66
Open
mwinter69
wants to merge
9
commits into
jenkinsci:master
Choose a base branch
from
mwinter69:noduplicate-sending
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
a25fb1f
avoid duplicate sending
mwinter69 3171eea
formatting and javadoc
mwinter69 547fb62
fix compile error
mwinter69 84a0adf
global mode
mwinter69 2c60a70
allow Notifier to run at end of build
mwinter69 654710f
exclude some enforcer rules
mwinter69 79033b3
reduce logging
mwinter69 dfe915e
remove unneeded dependency
mwinter69 455eb50
fix help for maxLines
mwinter69 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
src/main/java/jenkins/plugins/logstash/LogstashMarkerAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package jenkins.plugins.logstash; | ||
|
||
import org.kohsuke.accmod.Restricted; | ||
import org.kohsuke.accmod.restrictions.NoExternalUse; | ||
|
||
import hudson.Extension; | ||
import hudson.model.InvisibleAction; | ||
|
||
/* | ||
* A marker for Runs if logstash is enabled globally or set via JobProperty | ||
* When enabled globally or per JobProperty it doesn't make sense to send the data another time via a logstash step in a pipeline or | ||
* the logstashSend notifier | ||
*/ | ||
@Extension | ||
@Restricted(NoExternalUse.class) | ||
public class LogstashMarkerAction extends InvisibleAction | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 effectively makes you unable to have a single-document log generated from any build if global is enabled?
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.
yes but why you would want single document when you have it already line by line? Currently I don't distinguish between globally and set via JobProperty. We could also add a force option the Notifier.
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.
IMO best thing would be to have options to enable both modes globally and an ability to override this per-project.
Minimally I'm concerned about a situation when you want to enable the global option but you can't because of some existing projects rely on sending the single document
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.
Enabling globally to send everything at the end could be done in a
RunListener.onFinalized()
oronCompleted()
with the limitation that it can't fail the build.onFinalized()
would have the advantage that it includes the Final Result line, whileonCompleted()
would allow to write something to the log but which would not end up in the log sent to the indexer.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.
With the RunListener we could even get it right for pipeline as the Result is set when it's run. Avoiding all those questions about how to get the result in.
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.
Yes, though it is a complex topic and not yet sure how to implement in detail.
E.g. when you enable globally the notifier behaviour (just a single event at the end with the log), how to disable this in a project. Currently I would prefer the JobProperty for this. What if one specifies an explicit notifier in his job while it is also globally enabled. Which one should be taken and what when he wants to fail the build if upload fails (a runlistener can't modify the result anymore)? One could also enable the notifier behaviour via the JobProperty to replace the wrapper behaviour enabled globally. Should we allow a force of the notifier even when globally we have the wrapper enabled.
If we want to have full flexibility we might confuse people when they want to configure the jobs.
Maybe one could reduce it to the following.
A job specific setting overrides a global setting. You can disable the global setting without enabling a job setting. if a job enables the wrapper and configures the notifier only the wrapper will be used.
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.
Not sure if I understand the "You can disable the global setting without enabling a job setting. " part.
Agree that what is enabled on the job should win with the global setting. Also agree to only choose one if both are configured directly on the job. It would be nice to emit a warning in that case.
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.
Consider you have enabled it globally but for some reason, you don't want to upload the logs at all for a certain project.
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.
OK, but how do you propose to handle this? There is no explicit disable option at the moment (you could set maxLines=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.
via the JobProperty. It gets a checkbox to disable a global setting.