If you have a Queue.Executable that should consume an executor (so is not from a FlyweightTask), it unconditionally blocks "safe restart": RestartListener.Default merely checks for the existence of at least one busy executor. For an executable using the durable-task plugin or similar, this is undesirable, since the task can in fact survive a Jenkins restart. There should be a way to mark an Executable (or its parent Task) as not blocking restart.
There is already NonBlockingTask but this controls whether the task can be scheduled while Jenkins is quieting down, while this issue pertains to tasks which are already running and are safe to interrupt.
As an aside, Jenkins.doSafeExit inexplicably has its own copy of safe shutdown code which neglects to use doQuietDown(true, 0) like doSafeRestart does, and thus does not consider RestartListener.
- depends on
-
JENKINS-32015 Stop Groovy code execution during quietingDown
-
- Resolved
-
- is related to
-
JENKINS-25938 Lock an Executor without creating a Thread
-
- Resolved
-
-
JENKINS-26900 Hide flyweight master executor when ≥1 heavyweight executors running as subtasks
-
- Resolved
-
- links to
Also would like an API allowing the flyweight WorkflowRun executable to block a restart while in the middle of a CPS native method. This is especially important for a potentially slow operation like ArtifactArchiver.perform which cannot be stopped partway through. When Jenkins goes into quiet mode, new CPS-transformed calls should not start (so the program counter should pause), and any native methods currently running should be allowed to run to completion before shutdown occurs. This API could be very similar to the one above; essentially a way of customizing the logic of what constitutes a “running executable”.