-
Notifications
You must be signed in to change notification settings - Fork 122
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-34547] Switch WorkflowJob.concurrentBuild to JobProperty #8
Conversation
First work - tests still to come.
Hmm - looks like |
Or the test needs to go in |
} | ||
|
||
@Extension | ||
@Symbol("concurrentBuildProperty") |
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.
🐛 do not include property
in the symbol name. It is implicit in the extension point.
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.
Okiedokie - I was wary of just going with "concurrentBuild" since this is Pipeline-specific...
} | ||
|
||
public void setConcurrentBuild(boolean b) throws IOException { | ||
concurrentBuild = b ? null : false; |
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 you now need to unconditionally set concurrentBuild
to null. And deprecate this method.
Either way, you should start off by writing the @LocalData
-based tests which define what you expect to happen w.r.t. settings compatibility.
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, will do.
@@ -138,6 +140,9 @@ public WorkflowJob(ItemGroup parent, String name) { | |||
for (Trigger t : triggers) { | |||
t.start(this, Items.currentlyUpdatingByXml()); | |||
} | |||
if (concurrentBuild != null) { |
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 happy about this, but setConcurrentBuild(boolean)
alone wasn't enough to get the migration working.
Need to use |
@jglick - clarifying - you mean just a |
So the |
There's a nasty little contradiction - if we want just a checkbox in the UI, we need |
Having an OptionalJobProperty used solely as a boolean, effectively, means we need to have the default case be in effect when the property doesn't exist. That's different than the traditional concurrent build check, where the default is to not allow concurrent builds. Since we do want concurrent builds by default in Pipeline jobs, we need to instead have the property be for *disabling* concurrent builds. So...yeah. Not sure yet how to do a UI config test for an OptionalJobProperty - need to work on that.
Yes.
No strong opinion. Originally this was the only option for Pipeline. But for freestyle projects, the default has always been nonconcurrent, with the option for concurrent added later. Certainly we need to preserve the behavior of existing jobs.
Why is that? |
@@ -138,6 +140,9 @@ public WorkflowJob(ItemGroup parent, String name) { | |||
for (Trigger t : triggers) { | |||
t.start(this, Items.currentlyUpdatingByXml()); | |||
} | |||
if (concurrentBuild != null && !concurrentBuild) { |
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.
🐜 Do you not want to call setConcurrentBuild
even if it is false, just in case? Otherwise a true
value will stick around in config.xml
indefinitely. We would like to unconditionally delete the deprecated field.
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.
Yeah, you're right there. That was an artifact of earlier efforts. Fixing!
🐝 |
Though I tend to prefer concurrent by default, since to my way of thinking the serial option is a special behavior, akin to a |
So given that the default behavior has been to allow concurrent builds, I think that has to stay the same. Therefore, switching the UI from a checked-by-default checkbox for enabling concurrent builds to an unchecked-by-default checkbox for disabling concurrent builds seems eminently reasonable for me. |
Well…not for jobs saved since the
I am not opposed to that necessarily, though users might be confused that the UI is opposite that of freestyle projects. If we want to keep a consistent UI then we cannot use |
if (!b) { | ||
addProperty(new DisableConcurrentBuildsJobProperty()); | ||
|
||
boolean propertyExists = getProperty(DisableConcurrentBuildsJobProperty.class) == null; |
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 variable name is the opposite of the meaning.
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.
Also the comment was the inverse of what was actually being done. Whoops!
Yeah, the UI inconsistency is the only way I see to have just a checkbox with no further config in the UI, where it can also be disabled via the |
Well the alternative is a non- properties([concurrentBuilds(false)]) In some ways this is a little cleaner since it is apparent which jobs have been updated to the new format: all newly saved jobs should have the property. |
re:bee: |
Yeah, I considered the traditional JobProperty approach but dislike that UX more than changing the behavior. |
} | ||
bc.commit(); | ||
} finally { | ||
bc.abort(); |
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.
Why are we aborting after committing when successful?
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.
That was lifted from somewhere - lemme find it. I think that the abort
ends up doing nothing post-commit
....
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.
Ah, this was the paradigm used before jenkinsci/jenkins@5b4dbb3, and since we're not basing on HEAD of core, we still need to do things the old 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.
I mean yeah it shouldn't, but it's odd to me to do it there rather than an abort and re-throw on error.
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'm assuming that the paradigm is saying "Eh, if it goes wrong, just don't do it and move on"?
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.
shrug
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'd say the real issue isn't the code path - it's the name abort
, since what it really should be is something like cleanup
since it only aborts if the change is incomplete. Anyway, after that commit I linked above, it's irrelevant.
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.
Although... the alternative is pretty ugly (catch Exception, try to abort, then finally rethrow exception?).
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.
Meh. 🐝 and some grumping about the BulkChange APIs from me.
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 is correct here.
Yay, @reviewbybees done |
JENKINS-34547
cc @reviewbybees most especially @jglick