Class Reaper
- java.lang.Object
-
- hudson.slaves.ComputerListener
-
- org.csanchez.jenkins.plugins.kubernetes.pod.retention.Reaper
-
- All Implemented Interfaces:
ExtensionPoint
@Extension public class Reaper extends ComputerListener
Checks for deleted pods corresponding toKubernetesSlave
and ensures the node is removed from Jenkins too.If the pod has been deleted, all of the associated state (running user processes, workspace, etc.) must also be gone; so there is no point in retaining this agent definition any further. (
KubernetesSlave
is not anEphemeralNode
: it does support running across Jenkins restarts.)Note that pod retention policies other than the default
Never
may disable this system, unless some external process or garbage collection policy results in pod deletion.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
Reaper.Listener
Listener called when a Kubernetes event related to a Kubernetes agent happens.static class
Reaper.ReaperSaveableListener
SaveableListener
that will update cloud watchers when Jenkins configuration is updated.static class
Reaper.ReaperShutdownListener
Only useful for tests which shutdown Jenkins without terminating the JVM.static class
Reaper.RemoveAgentOnPodDeleted
static class
Reaper.TerminateAgentOnContainerTerminated
static class
Reaper.TerminateAgentOnImagePullBackOff
static class
Reaper.TerminateAgentOnPodFailed
-
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
-
Constructor Summary
Constructors Constructor Description Reaper()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Reaper
getInstance()
Map<String,?>
getWatchers()
void
maybeActivate()
void
preLaunch(Computer c, TaskListener taskListener)
Set<String>
terminationReasons(String node)
Get any reason(s) why a node was terminated by a listener.-
Methods inherited from class hudson.slaves.ComputerListener
all, onConfigurationChange, onLaunchFailure, onOffline, onOffline, onOnline, onOnline, onTemporarilyOffline, onTemporarilyOnline, preOnline, register, unregister
-
-
-
-
Method Detail
-
getInstance
public static Reaper getInstance()
-
preLaunch
public void preLaunch(Computer c, TaskListener taskListener) throws IOException, InterruptedException
- Overrides:
preLaunch
in classComputerListener
- Throws:
IOException
InterruptedException
-
maybeActivate
public void maybeActivate()
-
terminationReasons
@NonNull public Set<String> terminationReasons(@NonNull String node)
Get any reason(s) why a node was terminated by a listener.- Parameters:
node
- aNode.getNodeName()
- Returns:
- a possibly empty set of
ContainerStateTerminated.getReason()
orPodStatus.getReason()
-
-