-
Notifications
You must be signed in to change notification settings - Fork 273
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
[JENKINS-26010] Workflow compatibility #240
Conversation
@@ -118,7 +118,7 @@ public static DependencyQueueTaskDispatcher getInstance() { | |||
@Override | |||
public CauseOfBlockage canRun(Queue.Item item) { | |||
//AbstractProject check | |||
if (!(item.task instanceof AbstractProject)) { | |||
if (!(item.task instanceof Job)) { | |||
logger.debug("Not an abstract project: {}", item.task); |
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 log is a lie :)
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.
Thanks.
@scoheb, @GLundh, @TWestling I'm going on vacation today, so I won't be much help to @tfennelly during that time. Could you help him out with some friendly review? |
@rsandell: I would love to help out, but I'm going on vacation myself today, and wont be able to spend much time on it until early august. |
@rsandell ... I can definitely lend a hand! |
@tfennelly I'm willing to attempt running a version as well, to see how it goes. Let me know what I can do to help. Thanks for taking a serious stab at this one. |
@scoheb @GLundh @jacob-keller Thanks guys 🍺 ... I'll ping ye as soon as I have something testable. |
} else if (project.getHasCustomQuietPeriod() | ||
&& project.getQuietPeriod() > projectbuildDelay) { | ||
projectbuildDelay = project.getQuietPeriod(); | ||
} else if (project instanceof AbstractProject) { |
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.
ParameterizedJobMixing.ParameterizedJob
which both AbstractProject and Workflow implements has quietPeriod methods IIRC.
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.
Rights, but it doesn't have AbstractProject.getHasCustomQuietPeriod
. We'd have to drop that. Would that be a terrible thing and cause regressions?
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 getQuietPeriod
defaults if not set.
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.
I personally don't think that's an issue.
On Jul 10, 2015 9:42 AM, "Tom Fennelly" notifications@github.com wrote:
In
src/main/java/com/sonyericsson/hudson/plugins/gerrit/trigger/hudsontrigger/EventListener.java
#240 (comment)
:BadgeAction badgeAction = new BadgeAction(event); //during low traffic we still don't want to spam Gerrit, 3 is a nice number, isn't it? int projectbuildDelay = t.getBuildScheduleDelay(); if (cause instanceof GerritUserCause) { // it's a manual trigger, no need for a quiet period projectbuildDelay = 0;
} else if (project.getHasCustomQuietPeriod()
&& project.getQuietPeriod() > projectbuildDelay) {
projectbuildDelay = project.getQuietPeriod();
} else if (project instanceof AbstractProject) {
Note getQuietPeriod defaults if not set.
—
Reply to this email directly or view it on GitHub
https://github.com/jenkinsci/gerrit-trigger-plugin/pull/240/files#r34372420
.
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.
If not check AbstractProject.getHasCustomQuietPeriod
, ParameterizedJob.getQuietPeriod
might return system value given by Jenkins.getQuietPeriod
if quietPeriod
in project is not set. system's default is 5.
BTW, can we use GT's own period only?
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, if I understand this right, the old behavior was something like:
- If we're manual trigger, don't delay at all
- If the job has a custom quiet period (ie: not default) AND that period is larger than the ScheduleDelay, use this
- Otherwise, use the ScheduleDelay
So what's wrong with using the quietPeriodDelay even if it's not customized? Why can't we also check if we're above the default?
Is it so that GT's custom delay overrides the global default, but not per-jobs?
I'd rather use the longest of all configured delays, not the shortest. Ie: GT's delay only overrides global if the global is shorter?
We could also use only GT's trigger period, without worrying about per-job settings?
Thoughts?
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.
@jacob-keller @rinrinne guys, I'm afraid I don't really have a valuable opinion on stuff like this. I will be relying on ye to tell me what makes most sense from a Gerrit pov.
@@ -1918,8 +1928,12 @@ public synchronized void scheduled(ChangeBasedEvent event, ParametersAction para | |||
* The event that originally triggered the build. | |||
*/ | |||
private void cancelJob(GerritTriggeredEvent event) { | |||
if (!(job instanceof Queue.Task)) { | |||
logger.error("Error canceling job. The job is not of type Task."); | |||
} |
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.
I guess you should return directly after the logging?
And please log the task as well, so the admin knows which of the 10k jobs the log is talking about :)
@scoheb @jacob-keller Thanks guys! Then @tfennelly is in good hands while I relax with some 🍻 myself :) |
|
||
// TODO: find a way to handle add/remove of triggers | ||
if (!(job instanceof AbstractProject)) { | ||
return; |
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.
What would happen if it's an instance of WorkflowJob
?
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.
Does WorkflowJob have a way to add and remove triggers? I assume we'd want something similar to that? I know that the ParameterizedJobMixin does not have support for add triggers, but maybe we can just instanceOf to WorkflowJob here?
According to the source for WorkflowJob.java, it appears that WorkflowJob has an "addTrigger" function and getTriggers function, but this isn't exposed by the Mixin API. It would feel really awkward to instanceof and then use the same code both times.... Also, it doesn't support "getTrigger" standalone only the getTriggers...
Kind of ugly either way.
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 getTriggers()
method is defined in ParameterizedJobMixIn.ParameterizedJob
. We can cast to this one better than WorkflowJob
.
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.
@amuniz At the moment, nothing will happen for a Workflow Job i.e. add/remove of triggers is not supported for workflow as things stand. That's why I marked it with a TODO
. We need to find a way of handling it for workflow. AbstractProject
has methods for adding and removing triggers, but that's no help for a Workflow job.
Trigger rename
might be fixable by finding the current trigger and renaming the server on it Vs removing and readding the trigger (at the moment, rename
is supported by removing the trigger and adding a new one). Not sure yet how remove
will be supported (when a Gerrit server is removed we need to find all Jobs with triggers for that server and remove them).
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.
you can add a trigger easily. It seems like the trigger add code will remove the old trigger already. Sadly WorkflowJob.java does not export a remove trigger function like the code does. Maybe we just don't bother removing the old trigger at all when a server is removed?
What's the reason that we actually have remove/add trigger code here specifically? I presume to prevent a bug? What do other trigger plugins do to prevent this sort of issue?
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.
Auto removing zombie triggers after a Gerrit server is removed seems to make sense to me.
In any case (and imo), the debate on the pros and cons of programmatically removing a trigger is something that should happen separate to this PR. IMO, our job here is to integrate workflow and maintain the same feature set. It shouldn't be about proposing fundamental plugin design changes.
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.
On Jul 27, 2015 12:48 AM, "Tom Fennelly" notifications@github.com wrote:
In
src/main/java/com/sonyericsson/hudson/plugins/gerrit/trigger/GerritServer.java:@@ -914,14 +915,21 @@ private void rename(String newName) {
* @param oldName the old name of the Gerrit server
*/
private void changeSelectedServerInJobs(String oldName) {
PluginImpl.getConfiguredJobs_(oldName)) {for (AbstractProject job :
(GerritTrigger)job.getTrigger(GerritTrigger.class);GerritTrigger trigger =
for (Job job : PluginImpl.getConfiguredJobs_(oldName)) {
// TODO: find a way to handle add/remove of triggers
if (!(job instanceof AbstractProject)) {
return;
Auto removing zombie triggers after a Gerrit server is removed seems to
make sense to me.In any case (and imo), the debate on the pros and cons of
programmatically removing a trigger is something that should happen
separate to this PR. IMO, our job here is to integrate workflow and
maintain the same feature set. It shouldn't be about proposing fundamental
plugin design changes.—
Reply to this email directly or view it on GitHub.
While that is true.. I don't know of a good way to implement this
functionality and it may make sense to do the PR to remove such a feature
first unless we can actually do this change..
One way might be to optionally depend on work flow plug in. I have seen
others do this but I don't know how they did 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.
@jacob-keller Right, I didn't see a way of doing it for workflow. So, the easiest thing (for now) might be to mark it as a missing feature for Workflow jobs and not have that point block this PR?
Then, separately have a discussion on the merits/demerits etc of auto-removing triggers. This will either result in a task to remove the feature completely (for all build types), or a task to find a way of making it work for workflow.
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.
I think that is fine myself. I would rather not block trigger support just
because we are missing a relatively minor feature.
On Jul 27, 2015 3:42 AM, "Tom Fennelly" notifications@github.com wrote:
In
src/main/java/com/sonyericsson/hudson/plugins/gerrit/trigger/GerritServer.java
#240 (comment)
:@@ -914,14 +915,21 @@ private void rename(String newName) {
* @param oldName the old name of the Gerrit server
*/
private void changeSelectedServerInJobs(String oldName) {
for (AbstractProject job : PluginImpl.getConfiguredJobs_(oldName)) {
GerritTrigger trigger = (GerritTrigger)job.getTrigger(GerritTrigger.class);
for (Job job : PluginImpl.getConfiguredJobs_(oldName)) {
// TODO: find a way to handle add/remove of triggers
if (!(job instanceof AbstractProject)) {
return;
@jacob-keller https://github.com/jacob-keller Right, I didn't see a way
of doing it for workflow. So, the easiest thing (for now) might be to mark
it as a missing feature for Workflow jobs and not have that point block
this PR?Then, separately have a discussion on the merits/demerits etc of
auto-removing triggers. This will either result in a task to remove the
feature completely (for all build types), or a task to find a way of making
it work for workflow.—
Reply to this email directly or view it on GitHub
https://github.com/jenkinsci/gerrit-trigger-plugin/pull/240/files#r35523862
.
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.
Agreed with @tfennelly’s summary.
Thank you for a pull request! Please check this document for how the Jenkins project handles pull requests |
not sure if they pass though
@jacob-keller Where's that? |
The tests compile now, but there are failures galore :) Maybe you guys can help me make sense of these? |
There's a newer version, but 1.11.1 is the version that git-server 2.3 has a dep on.
Why is this not coming in as a transitive dep of jenkins-core ?
@tfennelly, it was suggested that you add the job name as part of the failure message, but you didn't get to that yet. |
if (project == null) { | ||
project = Hudson.getInstance().getItemByFullName(projectId, AbstractProject.class); | ||
project = Hudson.getInstance().getItemByFullName(projectId, Job.class); |
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.
inherital sin.
🐛 Found mostly just small nits. |
@rsandell I fixed what I reasonably could from your review. I don't think the others should hold up this PR so hopefully you can take back that bug please ;) |
@rsandell and if you can point me to the |
@rsandell oh and I purposely didn't touch/fix things like the use of |
🐝 |
@rsandell |
@tfennelly on the use of That does not apply to for example bad architecture that spans over multiple lines and files though. I did not ask you for example to convert the rebuild actions to use a transient factory even though you've touched lines in relation to that ;) |
@rsandell While I'm a person of zero religion/faith or supernatural beliefs of any kind now, I would have been born, baptised and educated within the Roman Catholic religion (as with most Irish people). So, I'm very familiar with sick ideas such as that of Ancestral/Original sin i.e. inheriting someone elses sins. So while I always thought I had been "cleansed" at baptism, I now find my sole has been tarnished with your bad deeds. Is that how it works? Grrrrrrrr 😸 |
@rsandell anyway ... back to the main point ... this PR needs to move forward if we can 😄 |
@@ -1149,14 +1154,6 @@ public void testGerritEventManualEvent() { | |||
trigger.createListener().gerritEvent(event); | |||
|
|||
verify(listener).onTriggered(same(project), same(event)); | |||
|
|||
verify(project).scheduleBuild2( |
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.
You are no longer verifying that the schedule2 method is actually called, the proxy above will only fail if it gets scheduled with bad parameters, but will pass the test if its not scheduled at all.
Repent and thou shall be merged! Sorry couldn't help myself 😈 Moving forward: I found some motivation to still not like the schedule thingie. 🐛 for removing the verify of schedule2. But I've gone through the rest and I it looks good. |
@rsandell fair point on the non-verify of the |
@rsandell ok, that should be ok now (assuming CI tests pass + over-picky checkstyles). |
Sorry @tfennelly I was a bit lazy in my last comment.
|
@rsandell added the As for the The |
But you did break the tests, they don't test the same thing any more. |
@rsandell specifically where are they not testing the same thing? You were saying that it was no longer verifying that the |
[JENKINS-26010] Workflow compatibility
I fixed the build failure and cleaned up the tests in 136d511 after the merge. |
@rsandell thanks for that Bobby. I'll take it for a drive and test it again. |
@reviewbybees done |
See JENKINS-26010
Current status: Ready for review. No more changes planned.
AbstractProject
toJob
in core coderebuild-plugin
git-plugin
AbstractBuild
toRun
in core code