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.FlyweightTaskis considered "trivial" and does not trigger termination. - A
OneOffExecutor(typically used by aQueue.FlyweightTask) is considered "trivial" and does not trigger termination. - A
ContinuableExecutablewhereContinuableExecutable.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.DemandNested 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 TypeMethodDescriptionlongprotected longprotected booleanprotected Stringprotected longbooleanintintbooleaninthashCode()booleanvoidsetNumberOfTasksInProgress(Integer numberOfTasksInProgress) voidsetTerminateOnceDone(Boolean terminateOnceDone) voidvoidtaskAccepted(Executor executor, Queue.Task task) voidtaskCompleted(Executor executor, Queue.Task task, long durationMS) voidtaskCompletedWithProblems(Executor executor, Queue.Task task, long durationMS, Throwable problems) protected voidMethods inherited from class hudson.slaves.RetentionStrategy
all, isManualLaunchAllowedMethods inherited from class hudson.model.AbstractDescribableImpl
getDescriptorMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods 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:
checkin classRetentionStrategy<DockerComputer>
-
start
- Overrides:
startin classRetentionStrategy<DockerComputer>
-
taskAccepted
- Specified by:
taskAcceptedin interfaceExecutorListener
-
taskCompleted
- Specified by:
taskCompletedin interfaceExecutorListener
-
taskCompletedWithProblems
public void taskCompletedWithProblems(Executor executor, Queue.Task task, long durationMS, Throwable problems) - Specified by:
taskCompletedWithProblemsin 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:
isAcceptingTasksin classRetentionStrategy<DockerComputer>
-
hashCode
public int hashCode() -
equals
-