jenkinsci / nomad-plugin

Nomad cloud plugin for Jenkins
https://plugins.jenkins.io/nomad/
MIT License
56 stars 41 forks source link

Check allocation success in plan before creating an actual job #185

Open arsiesys opened 1 year ago

arsiesys commented 1 year ago

What feature do you want to see added?

Hi,

Context 2 cloud provider configured in this order:

Problem When Jenkins detect an excess of workload, it will ask Nomad first and nomad will ALWAYS create a job in Nomad. If Nomad was out of ressources/available node to allocate the job, we will be in an infinite loop where jenkins will delete then recreate this job. The provisioning request will never reach the secondary node provider (GCP).

Solution

I made an example of implementation that I am experimenting for our needs: https://github.com/jenkinsci/nomad-plugin/commit/c80712c484e72fa2bed57954f63a5e60e27cf6b2

Someone with more skills in java could probably make it cleaner and even add an option to enable or not this behavior. This would made the plugin compatible with an other cloud provider.

Ressources https://developer.hashicorp.com/nomad/api-docs/jobs#create-job-plan https://github.com/jenkinsci/nomad-plugin/commit/c80712c484e72fa2bed57954f63a5e60e27cf6b2

Upstream changes

No response