jenkinsci / openstack-cloud-plugin

Provision nodes from OpenStack on demand
https://plugins.jenkins.io/openstack-cloud
MIT License
47 stars 83 forks source link

Only build jobs with label expression matching this node #199

Open balous opened 6 years ago

balous commented 6 years ago

I'd like to have an (openstack) agent reserved for special kind of jobs. This is why I use labels. But there are jobs without label specification that can be executed on any agent except the special one. For this, permanent agents have a setting switching between:

It seems that openstack cloud plugin is always creating nodes with the first option and there is no way to switch to the second one. As a result, unlabeled jobs are executed even on the special agent.

As an example, after some googling, I've found that Oracle Cloud plugin provides this feature:

https://github.com/jenkinsci/oracle-cloud-infrastructure-compute-plugin/blob/master/README.md#add-new-template

leighmhart commented 4 years ago

slave.setMode(hudson.model.Node.Mode.EXCLUSIVE)

Node.Mode.EXCLUSIVE maps to "Only build jobs with label restrictions matching this node." Node.Mode.NORMAL maps to "Utilize this node as much as possible"

It look like this was changed in https://github.com/jenkinsci/openstack-cloud-plugin/blob/master/src/main/java/jenkins/plugins/openstack/compute/JCloudsSlave.java#L93 at some point to address an issue https://github.com/jenkinsci/openstack-cloud-plugin/commit/9b96e1861f16abb50c2b27d0b17c35501c177a55

@olivergondza is this something that could be parameterised? We are using this plugin heavily in a shared environment and can't use alternatives like https://wiki.jenkins.io/display/JENKINS/Job+Restrictions+Plugin#JobRestrictionsPlugin-Jobrestrictionsfornodes to stop misconfigured jobs from using nodes not intended for their use.

appreciate any comments suggestions or otherwise!

olivergondza commented 3 years ago

I guess this needs to be configurable to make this other use-case working.

https://github.com/jenkinsci/openstack-cloud-plugin/commit/7aa9e7bfa7896f50d74aedfb9affa683558fb8c6 https://issues.jenkins.io/browse/JENKINS-29998