Package io.jenkins.plugins.swarmcloud
Class SwarmOnceRetentionStrategy
java.lang.Object
hudson.slaves.RetentionStrategy<AbstractCloudComputer<?>>
hudson.slaves.CloudSlaveRetentionStrategy<AbstractCloudComputer<?>>
io.jenkins.plugins.swarmcloud.SwarmOnceRetentionStrategy
- All Implemented Interfaces:
ExtensionPoint,Describable<RetentionStrategy<?>>,ExecutorListener
public class SwarmOnceRetentionStrategy
extends CloudSlaveRetentionStrategy<AbstractCloudComputer<?>>
implements ExecutorListener
Retention strategy for ephemeral one-shot Swarm agents (#7).
After the first completed build, the agent is removed and its underlying
Docker Swarm service is destroyed. Used when template.oneShot
is true. Modeled after the equivalent helper in the Jenkins
Kubernetes plugin — there is no OnceRetentionStrategy in
Jenkins core to reuse.
-
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.CloudSlaveRetentionStrategy
TIMEOUTFields inherited from class hudson.slaves.RetentionStrategy
INSTANCE, LIST, NOOP -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected longReturns the idle timeout in milliseconds for the parentCloudSlaveRetentionStrategy'scheck()loop.intvoidtaskAccepted(Executor executor, Queue.Task task) voidtaskCompleted(Executor executor, Queue.Task task, long durationMS) voidtaskCompletedWithProblems(Executor executor, Queue.Task task, long durationMS, Throwable problems) Methods inherited from class hudson.slaves.CloudSlaveRetentionStrategy
check, checkCycle, isIdleForTooLong, killMethods inherited from class hudson.slaves.RetentionStrategy
all, isAcceptingTasks, isManualLaunchAllowed, startMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface hudson.model.Describable
getDescriptorMethods inherited from interface hudson.model.ExecutorListener
taskStarted
-
Constructor Details
-
SwarmOnceRetentionStrategy
@DataBoundConstructor public SwarmOnceRetentionStrategy(int idleMinutes)
-
-
Method Details
-
getIdleMinutes
public int getIdleMinutes() -
getIdleMaxTime
protected long getIdleMaxTime()Returns the idle timeout in milliseconds for the parentCloudSlaveRetentionStrategy'scheck()loop. Without this override, the parent uses the staticCloudSlaveRetentionStrategy.TIMEOUTdefault (10 minutes) regardless of theidleMinutesvalue the constructor stored.Relevant only for the edge case "agent connected but no build was ever dispatched": in that case the parent's idle check eventually reaps the agent. The main one-shot path (build runs,
done(Executor)fires fromExecutorListener) terminates the agent immediately and does not depend on this method.- Overrides:
getIdleMaxTimein classCloudSlaveRetentionStrategy<AbstractCloudComputer<?>>
-
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
-