Description
Jenkins and plugins versions report
Environment
Jenkins 2.60.3
Plugin version : 2.61
What Operating System are you using (both controller, and any agents involved in the problem)?
Controller :
I used the latest (currently 2.60.3 ) docker image of Jenkins.
https://hub.docker.com/_/jenkins?tab=tags
Linux
Agents (not involved in the problem): Centos 7
Reproduction steps
- Launch and setup a Jenkins instance in a docker container
a. Command : docker run --name jenkinsInstance -p 8080:8080 -p 50000:50000 -v /var/jenkins_home jenkins
b. Setting up Jenkins : https://www.jenkins.io/doc/book/installing/docker/ - Install the OpenStack cloud plugin via the Manage plugin tabs
- Configure 2 clouds with the same label (in the templates)
- Create a multibranch pipeline project and link it to a git project :
a. Example : https://gitlab.com/AnderwanSAM/demo-project/-/tree/master
b. Details: The project has 4 branches. Each of them has a Jenkins file with jobs specifying the same label - Scan the project
- Remove the credentials of the first cloud
- try to build the jobs
Expected Results
The first cloud is unavailable. Hence the jobs should be built using the next available cloud with the same label.
Actual Results
The jobs hangs. The plugin ignores the failures and keep trying to provision nodes from the cloud that is down.
Anything else?
We have investigated and found that the exception thrown by getOpenStack() is not handled in the getAvailableTemplateProvider
method. I believe this is what causes the problem.
-
getOpenStack() : https://github.com/jenkinsci/openstack-cloud-plugin/blob/master/plugin/src/main/java/jenkins/plugins/openstack/compute/JCloudsCloud.java#L483
-
getAvailableTemplateProvider : https://github.com/jenkinsci/openstack-cloud-plugin/blob/master/plugin/src/main/java/jenkins/plugins/openstack/compute/JCloudsCloud.java#L258
Suggestion : handle the exception and return an empty queue. See this pull request :