Class DockerOnceRetentionStrategy
java.lang.Object
hudson.model.AbstractDescribableImpl<RetentionStrategy<?>>
hudson.slaves.RetentionStrategy<DockerComputer>
com.nirima.jenkins.plugins.docker.strategy.DockerOnceRetentionStrategy
- All Implemented Interfaces:
ExtensionPoint
,Describable<RetentionStrategy<?>>
,ExecutorListener
public class DockerOnceRetentionStrategy
extends RetentionStrategy<DockerComputer>
implements ExecutorListener
Retention strategy that allows our docker agents to run only a single build
before disconnecting.
- A
Queue.FlyweightTask
is considered "trivial" and does not trigger termination. - A
OneOffExecutor
(typically used by aQueue.FlyweightTask
) is considered "trivial" and does not trigger termination. - A
ContinuableExecutable
whereContinuableExecutable.willContinue()
is true does not trigger termination. - ...but any other workload will trigger termination once the node is idle.
OnceRetentionStrategy
(1.34) but with the kill/don't-kill decision made when we accept a task (not
when we complete it) and termination itself delayed until we've done all
ongoing work.-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class hudson.slaves.RetentionStrategy
RetentionStrategy.Always, RetentionStrategy.Demand
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
Field Summary
Fields inherited from class hudson.slaves.RetentionStrategy
INSTANCE, LIST, NOOP
-
Constructor Summary
ConstructorsConstructorDescriptionDockerOnceRetentionStrategy
(int idleMinutes) Creates the retention strategy. -
Method Summary
Modifier and TypeMethodDescriptionlong
protected long
protected boolean
protected String
protected long
boolean
int
int
boolean
int
hashCode()
boolean
void
setNumberOfTasksInProgress
(Integer numberOfTasksInProgress) void
setTerminateOnceDone
(Boolean terminateOnceDone) void
void
taskAccepted
(Executor executor, Queue.Task task) void
taskCompleted
(Executor executor, Queue.Task task, long durationMS) void
taskCompletedWithProblems
(Executor executor, Queue.Task task, long durationMS, Throwable problems) protected void
Methods inherited from class hudson.slaves.RetentionStrategy
all, isManualLaunchAllowed
Methods inherited from class hudson.model.AbstractDescribableImpl
getDescriptor
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface hudson.model.ExecutorListener
taskStarted
-
Constructor Details
-
DockerOnceRetentionStrategy
@DataBoundConstructor public DockerOnceRetentionStrategy(int idleMinutes) Creates the retention strategy.- Parameters:
idleMinutes
- number of minutes of idleness after which to kill the agent; serves a backup in case the strategy fails to detect the end of a task
-
-
Method Details
-
setTerminateOnceDone
-
setNumberOfTasksInProgress
-
getIdleMinutes
public int getIdleMinutes() -
getTerminateOnceDone
public boolean getTerminateOnceDone() -
getNumberOfTasksInProgress
public int getNumberOfTasksInProgress() -
check
- Specified by:
check
in classRetentionStrategy<DockerComputer>
-
start
- Overrides:
start
in classRetentionStrategy<DockerComputer>
-
taskAccepted
- Specified by:
taskAccepted
in interfaceExecutorListener
-
taskCompleted
- Specified by:
taskCompleted
in interfaceExecutorListener
-
taskCompletedWithProblems
public void taskCompletedWithProblems(Executor executor, Queue.Task task, long durationMS, Throwable problems) - Specified by:
taskCompletedWithProblems
in interfaceExecutorListener
-
computerIsIdle
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) protected boolean computerIsIdle(DockerComputer c) -
computerIdleStartMilliseconds
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) protected long computerIdleStartMilliseconds(DockerComputer c) -
currentMilliseconds
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) protected long currentMilliseconds() -
computerName
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) protected String computerName(DockerComputer c) -
terminateContainer
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) protected void terminateContainer(DockerComputer c) -
isAcceptingTasks
- Overrides:
isAcceptingTasks
in classRetentionStrategy<DockerComputer>
-
hashCode
public int hashCode() -
equals
-