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 Classes Modifier and Type Class Description static class
DockerOnceRetentionStrategy.DescriptorImpl
-
Nested 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
Constructors Constructor Description DockerOnceRetentionStrategy(int idleMinutes)
Creates the retention strategy.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long
check(DockerComputer c)
protected long
computerIdleStartMilliseconds(DockerComputer c)
protected boolean
computerIsIdle(DockerComputer c)
protected String
computerName(DockerComputer c)
protected long
currentMilliseconds()
boolean
equals(Object o)
int
getIdleMinutes()
int
getNumberOfTasksInProgress()
boolean
getTerminateOnceDone()
int
hashCode()
boolean
isAcceptingTasks(DockerComputer c)
void
setNumberOfTasksInProgress(Integer numberOfTasksInProgress)
void
setTerminateOnceDone(Boolean terminateOnceDone)
void
start(DockerComputer c)
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
terminateContainer(DockerComputer c)
-
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 Detail
-
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 Detail
-
setTerminateOnceDone
@DataBoundSetter public void setTerminateOnceDone(Boolean terminateOnceDone)
-
setNumberOfTasksInProgress
@DataBoundSetter public void setNumberOfTasksInProgress(Integer numberOfTasksInProgress)
-
getIdleMinutes
public int getIdleMinutes()
-
getTerminateOnceDone
public boolean getTerminateOnceDone()
-
getNumberOfTasksInProgress
public int getNumberOfTasksInProgress()
-
check
public long check(@NonNull DockerComputer c)
- Specified by:
check
in classRetentionStrategy<DockerComputer>
-
start
public void start(DockerComputer c)
- Overrides:
start
in classRetentionStrategy<DockerComputer>
-
taskAccepted
public void taskAccepted(Executor executor, Queue.Task task)
- Specified by:
taskAccepted
in interfaceExecutorListener
-
taskCompleted
public void taskCompleted(Executor executor, Queue.Task task, long durationMS)
- 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
public boolean isAcceptingTasks(DockerComputer c)
- Overrides:
isAcceptingTasks
in classRetentionStrategy<DockerComputer>
-
-