-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Adding basic retention #91
Conversation
jeffersongirao
commented
Nov 14, 2016
•
edited
Loading
edited
- The idea is to re-use slaves after successful builds, the slave is terminated after being idle for the time defined in idleMinutes. That is useful for builds that rely heavily on cached data for "speed".
|
||
/** | ||
* Kubernetes cloud provider. | ||
* | ||
* |
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.
it helps reviewing PRs if there are no spurious changes in imports or whitespace
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.
My bad, I reverted such changes.
@@ -44,9 +38,11 @@ | |||
|
|||
private transient final KubernetesCloud cloud; | |||
|
|||
@DataBoundConstructor | |||
@Deprecated |
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 there is no need to deprecate it
It should call the other constructor this(...)
to avoid duplication
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.
Fixed.
@@ -27,6 +27,10 @@ | |||
<f:textbox/> | |||
</f:entry> | |||
|
|||
<f:entry field="retainedAfterTask" title="${%Retain slave after 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.
instead of having a boolean, I think it's better to have idleMinutes
here, like the docker plugin, so it can be set per template for how long it should be kept
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.
Fixed.
Thanks for the feedback, I've made the suggested changes. Cheers! |
RetentionStrategy rs) | ||
throws Descriptor.FormException, IOException { | ||
|
||
this(template, nodeDescription, cloud, labelStr); |
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'd better do it the other way around, call this(template, nodeDescription, cloud, labelStr, rs);
in the first constructor, call super
in the second one
@@ -49,6 +49,8 @@ | |||
|
|||
private int instanceCap = Integer.MAX_VALUE; | |||
|
|||
private int idleMinutes = Integer.MIN_VALUE; |
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 not just use Integer and set it to 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.
Just afraid of NullPointerException in general. I will change it.
|
||
@DataBoundSetter | ||
public void setIdleMinutesStr(String idleMinutes) { | ||
if ("".equals(idleMinutes)) { |
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'd want to use StringUtils.isBlank()
not just the empty string
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.
Is it ok to introduce a dependency here? I was just trying to be consistent with what is implemented for setInstanceCapStr.
if (t.getIdleMinutes() == Integer.MIN_VALUE) { | ||
retentionStrategy = new OnceRetentionStrategy(cloud.getRetentionTimeout()); | ||
} else { | ||
retentionStrategy = new CloudRetentionStrategy(cloud.getRetentionTimeout()); |
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.
shouldn't be t.getIdleMinutes()
to use the idle time for the template ?
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 right, fixing it.
I did changes, please let me know if you prefer me to squash the commits in a single one. Cheers! |
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.
Just one last comment, and then it needs rebase
|
||
@Deprecated | ||
public KubernetesSlave(PodTemplate template, String nodeDescription, KubernetesCloud cloud, Label label) | ||
throws Descriptor.FormException, IOException { |
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.
can you just call
this(template, nodeDescription, cloud, label, new OnceRetentionStrategy(cloud.getRetentionTimeout()))
to avoid duplicated code
Fixed and rebased. Thanks! |
thanks! |
I'm not sure if this is the PR that caused our issues, but it's closely related, so I'll put this here: We use different docker images for each of our projects running on Jenkins using the kubernetes-plugin. I've noticed recently that a lot of times a job of project A might end up on a pod/container of project B. Because each pod/container setup is highly coupled to the different projects, a lot of tools are missing for project A to run inside a pod of project B, and thus the run fails. We haven't set the Something else that I noticed: since this PR(?) any custom pod template that we define in a Jenkinsfile gets automatically added to the list of global list of "Kubernetes Pod Template" configs in the global configuration page of Jenkins. This means that after a while, we end up with thousands of templates on that page, grinding that page to a halt. Possibly, this is the cause of the shared pod templates we are seeing? |
If I do a "reload from disk", the extra templates disappear from the global configuration (leaving only those that we actually defined in the global scope) |
Hello @JeanMertz, I tried to reproduce your issue but I could not. Could you please, give more details about the version of Jenkins you are trying it out and example of the Jenkinsfile? Thanks! |
Hi! Is there a way to keep slave forever? |