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

Option to limit run time of VM #408

Open
jglick opened this issue Aug 3, 2023 · 1 comment
Open

Option to limit run time of VM #408

jglick opened this issue Aug 3, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@jglick
Copy link
Member

jglick commented Aug 3, 2023

What feature do you want to see added?

CleanLostNodesWork tries to terminate VMs that no longer seem to be associated with any known Jenkins agent, but this still relies on the Jenkins controller to perform cleanup.

* <p>This ID allows us to find machines from our cloud in GCP. <b>This value should not change
* between config reload, or nodes may be lost in GCP side</b>
notes that this may not be foolproof; in particular, if you are using the configuration-as-code plugin to define a list of clouds, you may well neglect to set instanceId, in which case the id would be randomly reset every time JCasC was reapplied.

It would be useful to have an option to set .scheduling.maxRunDuration to ensure that an instance is automatically terminated if it has been accidentally left running for an unreasonably long time.

Even better, set .scheduling.terminationTime to a day in the future when the instance is created, and then replace CleanLostNodesWork with an hourly task to look for all connected GCE agents and update their termination time to be a day from then. This would guarantee that any abandoned VM will be terminated in a timely fashion no matter what happens to Jenkins, without imposing a particular time limit on how long a VM can legitimately be used as an agent if you happen to have an especially long build.

Upstream changes

I checked

private Scheduling scheduling() {
Scheduling scheduling = new Scheduling();
scheduling.setPreemptible(preemptible);
return scheduling;
}
but the current client library seems to lack support for this system. Perhaps it is too old? There seem to be multiple Java libraries that have been published by Google and it is not clear which one is preferred and supported. Recommend updating the client library version here and in dependencies such as google-oauth-plugin.

@jglick jglick added the enhancement New feature or request label Aug 3, 2023
@jglick
Copy link
Member Author

jglick commented May 7, 2024

See jenkinsci/kubernetes-plugin#1543 for an example of a similar feature.

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

No branches or pull requests

1 participant