Skip to content
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

Merged
merged 7 commits into from
Jul 13, 2016

Conversation

abayer
Copy link
Member

@abayer abayer commented Jul 12, 2016

JENKINS-34547

cc @reviewbybees most especially @jglick

@abayer
Copy link
Member Author

abayer commented Jul 12, 2016

Hmm - looks like JobPropertyStep may need to be moved into here for test purposes, at least.

@abayer
Copy link
Member Author

abayer commented Jul 12, 2016

Or the test needs to go in workflow-multibranch-plugin.git...

}

@Extension
@Symbol("concurrentBuildProperty")
Copy link
Member

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.

Copy link
Member Author

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;
Copy link
Member

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.

Copy link
Member Author

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) {
Copy link
Member Author

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.

@jglick
Copy link
Member

jglick commented Jul 12, 2016

Need to use configRoundTrip to see that the property can be saved & redisplayed on a non-multibranch project.

@abayer
Copy link
Member Author

abayer commented Jul 12, 2016

@jglick - clarifying - you mean just a JenkinsRule.configRoundTrip(job)?

@abayer
Copy link
Member Author

abayer commented Jul 13, 2016

So the OptionalJobProperty approach has actually broken this logic pretty hard - need to do some reworking.

@abayer
Copy link
Member Author

abayer commented Jul 13, 2016

There's a nasty little contradiction - if we want just a checkbox in the UI, we need OptionalJobProperty, but if we want to have concurrent builds enabled by default with a way to disable them from the properties step, OptionalJobProperty doesn't work. Grr.

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.
@jglick
Copy link
Member

jglick commented Jul 13, 2016

you mean just a JenkinsRule.configRoundTrip(job)

Yes.

if we want to have concurrent builds enabled by default

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.

with a way to disable them from the properties step, OptionalJobProperty doesn't work

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) {
Copy link
Member

@jglick jglick Jul 13, 2016

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.

Copy link
Member Author

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!

@jglick
Copy link
Member

jglick commented Jul 13, 2016

🐝

@jglick
Copy link
Member

jglick commented Jul 13, 2016

if we want to have concurrent builds enabled by default
No strong opinion.

Though I tend to prefer concurrent by default, since to my way of thinking the serial option is a special behavior, akin to a QueueTaskDispatcher which blocks builds from running under some conditions (example)—in this case, just that another build of the same job is currently running.

@abayer
Copy link
Member Author

abayer commented Jul 13, 2016

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.

@jglick
Copy link
Member

jglick commented Jul 13, 2016

given that the default behavior has been to allow concurrent builds, I think that has to stay the same

Well…not for jobs saved since the concurrentBuild field was added. But for really old jobs last saved before there was even the option, yes.

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

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 OptionalJobProperty, I am afraid.

if (!b) {
addProperty(new DisableConcurrentBuildsJobProperty());

boolean propertyExists = getProperty(DisableConcurrentBuildsJobProperty.class) == null;
Copy link
Member

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.

Copy link
Member Author

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!

@abayer
Copy link
Member Author

abayer commented Jul 13, 2016

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 properties step. Not to mention there's a challenge in getting an OptionalJobProperty to be selected by default!

@jglick
Copy link
Member

jglick commented Jul 13, 2016

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 properties step

Well the alternative is a non-Optional JobProperty whose config view has a checkbox in it (checked by default), and from Jenkinsfile you would need to write something like

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.

@jglick
Copy link
Member

jglick commented Jul 13, 2016

re:bee:

@abayer
Copy link
Member Author

abayer commented Jul 13, 2016

Yeah, I considered the traditional JobProperty approach but dislike that UX more than changing the behavior.

}
bc.commit();
} finally {
bc.abort();
Copy link
Member

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?

Copy link
Member Author

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....

Copy link
Member Author

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.

Copy link
Member

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.

Copy link
Member Author

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"?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shrug

Copy link
Member Author

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.

Copy link
Member

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?).

Copy link
Member

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.

Copy link
Member

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.

@abayer
Copy link
Member Author

abayer commented Jul 13, 2016

Yay, @reviewbybees done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants