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

Set nodeUsageMode to EXCLUSIVE as default #386

Merged
merged 2 commits into from
Feb 15, 2019
Merged

Set nodeUsageMode to EXCLUSIVE as default #386

merged 2 commits into from
Feb 15, 2019

Conversation

TobiX
Copy link
Contributor

@TobiX TobiX commented Oct 21, 2018

This is an attempt to give "nodeUsageMode" more visibility, due to a "race-condition" discovered while this was set to its default value "NORMAL" (other jobs "stealing" the pod from a job).

PS: Having @DataBoundSetter on two overloads of the same method seems to confuse the snippet generator... Switching the order of those cases fixed it for me... (Maybe removing the non-String version is the "correct" fix, but might break backwards compatibility)

@carlossg
Copy link
Contributor

can you split the PR for nodeUsageMode and cleanup, will make it easier to review and merge

@TobiX
Copy link
Contributor Author

TobiX commented Oct 21, 2018

@carlossg I'll try. The changes are not quite independent, since the changed lines in each commit are right next to each other... (OTOH, reviewing each commit on its own should be possible)

@TobiX TobiX mentioned this pull request Oct 21, 2018
@TobiX
Copy link
Contributor Author

TobiX commented Oct 23, 2018

Rebased after clean-up stuff moved into its own pull request.

Copy link
Contributor

@carlossg carlossg left a comment

Choose a reason for hiding this comment

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

I don't know if this makes sense, if EXCLUSIVE solves anything then it should be the default, but I don't think it really changes the execution for kubernetes agents. Can you elaborate?

}

@DataBoundSetter
public void setNodeUsageMode(String nodeUsageMode) {
this.nodeUsageMode = Node.Mode.valueOf(nodeUsageMode);
public void setNodeUsageMode(Node.Mode nodeUsageMode) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think if @DataBoundSetter is removed you wouldn't have the ordering issue

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed it and it seems you are right.

@TobiX
Copy link
Contributor Author

TobiX commented Oct 31, 2018

Sure: FreeStyle jobs without node specification (can run an "any" node) are scheduled on Kubernetes nodes with nodeUsageMode: 'NORMAL' (the default) in the small gap between pod creation and running the node {} block inside the podTemplate - It seems there is a small timeframe where the node is "free" and Jenkins decides to schedule another job on the node.... This is pretty rare (happend about 3 or 4 times in 2 months), but it happens.

@Vlatombe
Copy link
Member

Vlatombe commented Nov 7, 2018

I agree with @carlossg, it should be the default as long as there is a label defined for the pod template

@TobiX
Copy link
Contributor Author

TobiX commented Nov 30, 2018

To get back to this: @Vlatombe @carlossg Should I create a pull request implementing EXCLUSIVE as default if a label is specified?

@carlossg
Copy link
Contributor

yes, the defaulting to exclusive should be in this PR

Copy link
Contributor

@carlossg carlossg left a comment

Choose a reason for hiding this comment

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

EXCLUSIVE should be the default

@TobiX TobiX changed the title "nodeUsageMode" visibility Set nodeUsageMode to EXCLUSIVE as default Jan 18, 2019
TobiX and others added 2 commits January 18, 2019 13:26
This changes the behavior for existing podTemplate() pipeline steps (for
the better IMHO). This will (obviously) not update existing persisted
pod templates, users will need to fix them manually.
@TobiX
Copy link
Contributor Author

TobiX commented Jan 18, 2019

I'm not really happy with specifying the default both in the code and in the Jelly template, but it seems the Jelly template is rendered without any object (not even an empty object) first and only when submitting the form an object is created...

The behaviour is now like this: Both Jelly forms (the snippet generator for pipelines and the pod template form in Jenkins' system settings) now preselect "EXCLUSIVE", to give the unsuspecting user the strong hint that this is the correct setting.

The default in PodTemplateStep comes into play when the user uses the podTemplate() pipeline step without specifying any nodeUsageMode (this is a behaviour change). The default in PodTemplate is for good measure 🤷‍♂️

@carlossg carlossg merged commit f3d2586 into jenkinsci:master Feb 15, 2019
@TobiX TobiX deleted the nodeusagemode-visibility branch May 22, 2019 07:16
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