Package com.amazon.jenkins.ec2fleet
Class EC2FleetCloud
java.lang.Object
hudson.model.AbstractModelObject
hudson.model.Actionable
hudson.slaves.Cloud
com.amazon.jenkins.ec2fleet.AbstractEC2FleetCloud
com.amazon.jenkins.ec2fleet.EC2FleetCloud
- All Implemented Interfaces:
ExtensionPoint
,Describable<Cloud>
,ModelObject
,SearchableModelObject
,SearchItem
,AccessControlled
,ModelObjectWithContextMenu
The
EC2FleetCloud
contains the main configuration values used while creating Jenkins nodes.
EC2FleetCloud can represent either an AWS EC2 Spot Fleet or an AWS AutoScalingGroup.
Responsibilities include:
* maintain the configuration values set by user for the Cloud.
User-initiated changes to such configuration will result in a new EC2FleetCloud object. See Cloud
.
* provision new EC2 capacity along with supporting provisioning checks for EC2FleetCloud
* keep FleetStateStats
in sync with state on the AWS side via update()
* provide helper methods to extract certain state values
* provide helper methods to schedule termination of compute / nodes-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
static class
static class
static class
static class
static class
Nested classes/interfaces inherited from class hudson.slaves.Cloud
Cloud.CloudState
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
Nested classes/interfaces inherited from interface jenkins.model.ModelObjectWithContextMenu
ModelObjectWithContextMenu.ContextMenu, ModelObjectWithContextMenu.ContextMenuVisibility, ModelObjectWithContextMenu.MenuItem, ModelObjectWithContextMenu.MenuItemType
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionEC2FleetCloud
(String name, String awsCredentialsId, String credentialsId, String region, String endpoint, String fleet, String labelString, String fsRoot, ComputerConnector computerConnector, boolean privateIpUsed, boolean alwaysReconnect, Integer idleMinutes, int minSize, int maxSize, int minSpareSize, int numExecutors, boolean addNodeOnlyIfRunning, boolean restrictUsage, String maxTotalUses, boolean disableTaskResubmit, Integer initOnlineTimeoutSec, Integer initOnlineCheckIntervalSec, Integer cloudStatusIntervalSec, boolean noDelayProvision, boolean scaleExecutorsByWeight, EC2FleetCloud.ExecutorScaler executorScaler) -
Method Summary
Modifier and TypeMethodDescriptionboolean
canProvision
(Cloud.CloudState cloudState) Deprecated.UseawsCredentialsId
SeeawsCredentialsId
documentation.int
getFleet()
int
int
int
int
int
int
int
int
int
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
provision
(Cloud.CloudState cloudState, int excessWorkload) boolean
removePlannedNodeScheduledFutures
(int numToRemove) boolean
scheduleToTerminate
(String instanceId, boolean ignoreMinConstraints, EC2AgentTerminationReason reason) Schedules Jenkins Node and EC2 instance for termination.update()
Perform sync of plugin data with EC2 Spot Fleet state.Methods inherited from class hudson.slaves.Cloud
all, canProvision, doConfigSubmit, doDoDelete, getACL, getDisplayName, getIcon, getIconAltText, getIconClassName, getSearchUrl, getUrl, provision, reconfigure, reconfigure, registerPermissions
Methods inherited from class hudson.model.Actionable
addAction, addOrReplaceAction, doContextMenu, doContextMenu, getAction, getAction, getActions, getActions, getAllActions, getDynamic, getDynamic, removeAction, removeActions, replaceAction, replaceActions
Methods inherited from class hudson.model.AbstractModelObject
getSearch, getSearchIndex, getSearchName, makeSearchIndex, requirePOST, sendError, sendError, sendError, sendError, sendError, sendError, sendError, sendError
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface hudson.security.AccessControlled
checkAnyPermission, checkPermission, hasAnyPermission, hasPermission, hasPermission, hasPermission2
Methods inherited from interface hudson.search.SearchItem
getSearchIcon
-
Field Details
-
EC2_INSTANCE_TAG_NAMESPACE
- See Also:
-
EC2_INSTANCE_CLOUD_NAME_TAG
- See Also:
-
BASE_DEFAULT_FLEET_CLOUD_ID
- See Also:
-
DEFAULT_CLOUD_STATUS_INTERVAL_SEC
public static final int DEFAULT_CLOUD_STATUS_INTERVAL_SEC- See Also:
-
-
Constructor Details
-
EC2FleetCloud
@DataBoundConstructor public EC2FleetCloud(@Nonnull String name, String awsCredentialsId, @Deprecated String credentialsId, String region, String endpoint, String fleet, String labelString, String fsRoot, ComputerConnector computerConnector, boolean privateIpUsed, boolean alwaysReconnect, Integer idleMinutes, int minSize, int maxSize, int minSpareSize, int numExecutors, boolean addNodeOnlyIfRunning, boolean restrictUsage, String maxTotalUses, boolean disableTaskResubmit, Integer initOnlineTimeoutSec, Integer initOnlineCheckIntervalSec, Integer cloudStatusIntervalSec, boolean noDelayProvision, boolean scaleExecutorsByWeight, EC2FleetCloud.ExecutorScaler executorScaler)
-
-
Method Details
-
isNoDelayProvision
public boolean isNoDelayProvision() -
getAwsCredentialsId
Deprecated.UseawsCredentialsId
SeeawsCredentialsId
documentation. Don't use fields directly to be able get old version of plugin and for new.- Returns:
- credentials ID
-
isDisableTaskResubmit
public boolean isDisableTaskResubmit()- Specified by:
isDisableTaskResubmit
in classAbstractEC2FleetCloud
-
getInitOnlineTimeoutSec
public int getInitOnlineTimeoutSec() -
getScheduledFutureTimeoutSec
public int getScheduledFutureTimeoutSec() -
getCloudStatusIntervalSec
public int getCloudStatusIntervalSec() -
getInitOnlineCheckIntervalSec
public int getInitOnlineCheckIntervalSec() -
getRegion
-
getEndpoint
-
getFleet
-
getFsRoot
-
isAddNodeOnlyIfRunning
public boolean isAddNodeOnlyIfRunning() -
getComputerConnector
-
isPrivateIpUsed
public boolean isPrivateIpUsed() -
isAlwaysReconnect
public boolean isAlwaysReconnect()- Specified by:
isAlwaysReconnect
in classAbstractEC2FleetCloud
-
getLabelString
-
getIdleMinutes
public int getIdleMinutes()- Specified by:
getIdleMinutes
in classAbstractEC2FleetCloud
-
getMaxSize
public int getMaxSize() -
getMinSize
public int getMinSize() -
getMinSpareSize
public int getMinSpareSize() -
getMaxTotalUses
public int getMaxTotalUses() -
getNumExecutors
public int getNumExecutors() -
isScaleExecutorsByWeight
public boolean isScaleExecutorsByWeight() -
getExecutorScaler
-
getJvmSettings
-
isRestrictUsage
public boolean isRestrictUsage() -
hasUnlimitedUsesForNodes
public boolean hasUnlimitedUsesForNodes() -
hasExcessCapacity
public boolean hasExcessCapacity()- Specified by:
hasExcessCapacity
in classAbstractEC2FleetCloud
-
provision
public Collection<NodeProvisioner.PlannedNode> provision(@Nonnull Cloud.CloudState cloudState, int excessWorkload) -
update
Perform sync of plugin data with EC2 Spot Fleet state.- Returns:
- current state
-
removePlannedNodeScheduledFutures
public boolean removePlannedNodeScheduledFutures(int numToRemove) -
scheduleToTerminate
public boolean scheduleToTerminate(String instanceId, boolean ignoreMinConstraints, EC2AgentTerminationReason reason) Schedules Jenkins Node and EC2 instance for termination. IfignoreMinConstraints
is false and target capacity falls belowminSize
ORminSpareSize
thresholds, then reject termination. Else ifignoreMinConstraints
is true, schedule instance for termination even if it breachesminSize
ORminSpareSize
Real termination will happens in
update()
which is periodically called byCloudNanny
. So there could be some lag between the decision to terminate the node and actual termination, you can find max lag size inCloudNanny.getRecurrencePeriod()
This method doesn't do real termination to reduce load for Jenkins in case when multiple nodes should be terminated in short time, without schedule process and batch termination, multiple calls should be raised to AWS EC2 API which takes some time and block cloud class.
- Specified by:
scheduleToTerminate
in classAbstractEC2FleetCloud
- Parameters:
instanceId
- node name or instance IDignoreMinConstraints
- terminate instance even if it breaches min size constraintreason
- reason for termination- Returns:
true
if node scheduled for termination, otherwisefalse
-
canProvision
- Overrides:
canProvision
in classCloud
-
getDescriptor
- Specified by:
getDescriptor
in interfaceDescribable<Cloud>
- Overrides:
getDescriptor
in classCloud
-