Enable starting executors in paused mode

In some cases, especially on systems under heavy load, it is
helpful to start executors in paused mode. Preventing them
to start accepting new jobs right away until such executors
are unpaused manually allows to test new features, configuration
or with analysing production problems.

Change-Id: I64c39e3b58c802577201280c855fdf7f13cc7538
This commit is contained in:
Jan Kubovy 2019-11-04 13:07:39 +01:00
parent 22af945568
commit 1f8a93b27b
3 changed files with 12 additions and 3 deletions

View File

@ -751,6 +751,12 @@ The following sections of ``zuul.conf`` are used by the executor:
where it cannot determine its hostname correctly this can be overridden
here.
.. attr:: paused_on_start
:default: false
Whether the executor should start in a paused mode. Such executor will not
accept tasks until it is unpaused.
.. attr:: zone
:default: None

View File

@ -20,8 +20,8 @@ from zuul.executor.sensors import SensorInterface
class PauseSensor(SensorInterface):
log = logging.getLogger("zuul.executor.sensor.pause")
def __init__(self):
self.pause = False
def __init__(self, pause=False):
self.pause = pause
def isOk(self):
if self.pause:

View File

@ -2401,7 +2401,10 @@ class ExecutorServer(object):
self.stopJobDiskFull,
self.merge_root)
self.pause_sensor = PauseSensor()
self.pause_sensor = PauseSensor(get_default(self.config, 'executor',
'paused_on_start', False))
self.log.info("Starting executor (hostname: %s) in %spaused mode" % (
self.hostname, "" if self.pause_sensor.pause else "un"))
cpu_sensor = CPUSensor(config)
self.sensors = [
cpu_sensor,