It is not possible to set number of executors of Controllers

Issue

It is not possible to set number of executors of Controllers with the following approaches:

When the Controller is restarted the number of executors returns to 0. This can cause unexpected behavior during a period of time until the enforcement process is completed.

The Controller startup logs show something like the following:

2021-10-19 03:31:44.547+0000 [id=28]	INFO	jenkins.InitReactorRunner$1#onAttained: Listed all plugins
2021-10-19 03:32:01.515+0000 [id=28]	INFO	jenkins.InitReactorRunner$1#onAttained: Prepared all plugins
2021-10-19 03:32:04.815+0000 [id=27]	INFO	jenkins.InitReactorRunner$1#onAttained: Started all plugins
2021-10-19 03:32:04.937+0000 [id=27]	INFO	jenkins.InitReactorRunner$1#onAttained: Augmented all extensions
2021-10-19 03:32:07.611+0000 [id=27]	INFO	jenkins.InitReactorRunner$1#onAttained: System config loaded
2021-10-19 03:32:08.825+0000 [id=27]	INFO	jenkins.InitReactorRunner$1#onAttained: System config adapted
2021-10-19 03:32:08.826+0000 [id=28]	INFO	jenkins.InitReactorRunner$1#onAttained: Loaded all jobs
[...]
2021-10-19 03:32:11.126+0000 [id=28]	INFO	jenkins.InitReactorRunner$1#onAttained: Configuration for all jobs updated
[...]
2021-10-19 03:32:12.723+0000 [id=57]	INFO	c.c.o.c.p.OperationsCenterRootAction$DescriptorImpl#setApprovedState: Approved
2021-10-19 03:32:13.225+0000 [id=57]	INFO	c.c.o.c.p.OperationsCenterRootAction$DescriptorImpl#setConnectedState: Connected
[...]
2021-10-19 03:32:13.345+0000 [id=28]	INFO	j.util.groovy.GroovyHookScript#execute: Executing /var/jenkins_home/init.groovy.d/init_01_launch_configure_jenkins.groovy
[...]
2021-10-19 03:32:24.912+0000 [id=28]	INFO	j.util.groovy.GroovyHookScript#execute: Executing /var/jenkins_home/configure-jenkins.groovy.d/01-master-executors.groovy
--> disabling controller executors
[...]
2021-10-19 03:32:46.734+0000 [id=28]	INFO	jenkins.InitReactorRunner$1#onAttained: Completed initialization
2021-10-19 03:32:47.208+0000 [id=21]	INFO	hudson.WebAppMain$3#run: Jenkins is fully up and running

The 01-master-executors.groovy hook script which is provided by CloudBees official images is responsible for setting the number of executors back to 0. This enforcement is expected and it is one of the CloudBees recommendations that Operations Center and Controllers have 0 executors. You can check below the 01-master-executors.groovy source code for better understanding:

import hudson.model.*;
import jenkins.model.*;

println "--> disabling controller executors"
Jenkins.instance.setNumExecutors(0)

Environment

Resolution

There is no current resolution as the enforcement is one of the CloudBees recommendations that Operations Center and Controllers have 0 executors.

Workaround

Official image customization

You could customize your Controller images to either remove that init script or modify the number of executors that are established in it.

Enforce number of executors from Operations Center

At http://YOUR_DOMAIN/cjoc/configureSecurity/ you could set the desired number of executors:

Connected controller on-controller executors

After every Controller restart the 01-master-executors.groovy will be executed setting the number of executors to 0 but after a short period of time the enforcement will take place. The enforcement can also be done via Configuration as Code for the Operations Center

Add an additional init.d script

An additional init.d script would be executed after 01-master-executors.groovy. For example named as init_02_SCRIPT_CUSTOM_NAME or with a prefix that comes after this fix alphanumerically. You should place the script under ${JENKINS_HOME}/init.groovy.d. After placing it there and restart your instance you should see in the startup logs something like the following:

2022-04-04 14:20:21.523+0000 [id=74]	INFO	c.c.o.c.p.OperationsCenterRootAction$DescriptorImpl#setConnectedState: Connected
2022-04-04 14:20:21.539+0000 [id=28]	INFO	j.util.groovy.GroovyHookScript#execute: Executing /var/jenkins_home/configure-jenkins.groovy.d/01-master-executors.groovy
--> disabling controller executors
2022-04-04 14:20:22.024+0000 [id=28]	INFO	j.util.groovy.GroovyHookScript#execute: Executing /var/jenkins_home/init.groovy.d/init_02_controller_executors.groovy
--> disabling controller executors
2022-04-04 14:20:22.274+0000 [id=28]	INFO	jenkins.InitReactorRunner$1#onAttained: Completed initialization
2022-04-04 14:20:22.347+0000 [id=22]	INFO	hudson.lifecycle.Lifecycle#onReady: Jenkins is fully up and running
2022-04-04 14:20:22.837+0000 [id=50]	INFO	c.c.j.p.a.m.UpdateSiteDataProvider$Value#get: Beekeeper is parsing UpdateSite cap-core-mm
2022-04-04 14:20:24.045+0000 [id=94]	INFO	hudson.license.LicenseListener#fireAfterUpdate: firing the license update notification

Have more questions?

0 Comments

Please sign in to leave a comment.