Package io.jenkins.plugins.kubevirt
Class KubeVirtAgent
java.lang.Object
hudson.model.AbstractModelObject
hudson.model.Node
hudson.model.Slave
hudson.slaves.AbstractCloudSlave
io.jenkins.plugins.kubevirt.KubeVirtAgent
- All Implemented Interfaces:
ExtensionPoint,Describable<Node>,ModelObject,PersistenceRoot,ReconfigurableDescribable<Node>,Saveable,SearchableModelObject,SearchItem,AccessControlled,Serializable,OnMaster,org.jenkinsci.plugins.cloudstats.TrackedItem
public class KubeVirtAgent
extends AbstractCloudSlave
implements org.jenkinsci.plugins.cloudstats.TrackedItem
Jenkins agent running on a KubeVirt virtual machine.
Implements TrackedItem for cloud-stats plugin integration.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classstatic enumReasons why a KubeVirt agent can be terminated.Nested classes/interfaces inherited from class hudson.model.Slave
Slave.JnlpJar, Slave.SlaveDescriptorNested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson -
Field Summary
Fields inherited from class hudson.model.Node
holdOffLaunchUntilSave, SKIP_BUILD_CHECK_ON_FLYWEIGHTS -
Constructor Summary
ConstructorsConstructorDescriptionKubeVirtAgent(String name, String cloudName, String templateName, String remoteFS, ComputerLauncher launcher, String labelString, String provisioningInfo, int idleMinutes, org.jenkinsci.plugins.cloudstats.ProvisioningActivity.Id provisioningId) Creates a new KubeVirt agent. -
Method Summary
Modifier and TypeMethodDescriptionprotected void_terminate(TaskListener listener) org.jenkinsci.plugins.cloudstats.ProvisioningActivity.IdgetId()Gets the provisioning activity ID for cloud-stats tracking.intGets the configured idle minutes for this agent.Gets the provisioning information captured during VM creation.Gets the name of the template that was used to create this agent.Gets the termination reason, or infers it from the agent configuration if not explicitly set.booleanReturns true if this is a single-use agent (idleMinutes == 0).voidsetProvisioningInfo(String provisioningInfo) Sets the provisioning information.voidSets the reason for termination.booleanClaims this launch for provisioning-failure tracking.Methods inherited from class hudson.slaves.AbstractCloudSlave
terminateMethods inherited from class hudson.model.Slave
createLauncher, drainLabelsToTrim, equals, getClockDifferenceCallable, getComputer, getLabelAtomSet, getLabelString, getLauncher, getMode, getNodeDescription, getNodeName, getNodeProperties, getNumExecutors, getRemoteFS, getRetentionStrategy, getRootPath, getUserId, getWorkspaceFor, getWorkspaceRoot, hashCode, readResolve, save, setLabelString, setLauncher, setMode, setNodeDescription, setNodeName, setNodeProperties, setNumExecutors, setRetentionStrategy, setUserId, toStringMethods inherited from class hudson.model.Node
canTake, canTake, createPath, getACL, getAssignedLabels, getChannel, getClockDifference, getConfigFile, getDisplayName, getFileSystemProvisioner, getLabelCloud, getNodeProperty, getNodeProperty, getNodePropertyDescriptors, getRootDir, getSearchUrl, getSelfLabel, getTemporaryOfflineCause, isAcceptingTasks, isHoldOffLaunchUntilSave, onLoad, reconfigure, reconfigure, setTemporaryOfflineCause, toComputerMethods inherited from class hudson.model.AbstractModelObject
getSearch, getSearchIndex, getSearchName, makeSearchIndex, requirePOST, sendError, sendError, sendError, sendError, sendError, sendError, sendError, sendErrorMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface hudson.security.AccessControlled
checkAnyPermission, checkPermission, hasAnyPermission, hasPermission, hasPermission, hasPermission2Methods inherited from interface hudson.search.SearchItem
getSearchGroup, getSearchIcon
-
Constructor Details
-
KubeVirtAgent
public KubeVirtAgent(String name, String cloudName, String templateName, String remoteFS, ComputerLauncher launcher, String labelString, String provisioningInfo, int idleMinutes, org.jenkinsci.plugins.cloudstats.ProvisioningActivity.Id provisioningId) throws Descriptor.FormException, IOException Creates a new KubeVirt agent.- Parameters:
name- The node name (also the VM name)cloudName- The name of the KubeVirt cloud that created this agenttemplateName- The name of the template used to create this agentremoteFS- The remote filesystem path for the agentlauncher- The computer launcherlabelString- Labels for this agentprovisioningInfo- Provisioning log informationidleMinutes- Idle timeout in minutes (0 = single-use)provisioningId- The cloud-stats provisioning activity ID- Throws:
Descriptor.FormExceptionIOException
-
-
Method Details
-
isSingleUse
public boolean isSingleUse()Returns true if this is a single-use agent (idleMinutes == 0). Single-use agents should be disposed immediately after the first build completes.- Returns:
- true if this is a single-use agent
-
getIdleMinutes
public int getIdleMinutes()Gets the configured idle minutes for this agent.- Returns:
- The idle timeout in minutes (0 means single-use)
-
getProvisioningInfo
Gets the provisioning information captured during VM creation. This is displayed in the computer log when the agent comes online.- Returns:
- The provisioning info, or null if not available
-
setProvisioningInfo
Sets the provisioning information. Called by theKubeVirtProvisioningLauncherafter provisioning completes (or fails) so the build console can display it.- Parameters:
provisioningInfo- The provisioning log text
-
getCloudName
-
getTemplateName
Gets the name of the template that was used to create this agent.- Returns:
- The template name
-
setTerminationReason
Sets the reason for termination. Call this before calling terminate() to ensure the correct offline cause is reported.- Parameters:
reason- The reason for termination
-
tryMarkProvisioningFailureHandled
public boolean tryMarkProvisioningFailureHandled()Claims this launch for provisioning-failure tracking.- Returns:
trueif this is the first claim and the caller should record (or explicitly skip) the failure;falseif another path already handled this launch
-
getTerminationReason
Gets the termination reason, or infers it from the agent configuration if not explicitly set.- Returns:
- The termination reason, never null
-
getId
public org.jenkinsci.plugins.cloudstats.ProvisioningActivity.Id getId()Gets the provisioning activity ID for cloud-stats tracking. This links the agent to its provisioning activity in the cloud-stats plugin.- Specified by:
getIdin interfaceorg.jenkinsci.plugins.cloudstats.TrackedItem- Returns:
- The provisioning activity ID
-
createComputer
- Specified by:
createComputerin classAbstractCloudSlave
-
getDescriptor
- Specified by:
getDescriptorin interfaceDescribable<Node>- Overrides:
getDescriptorin classSlave
-
_terminate
- Specified by:
_terminatein classAbstractCloudSlave- Throws:
IOExceptionInterruptedException
-