Class Cloud
- All Implemented Interfaces:
ExtensionPoint
,Describable<Cloud>
,ModelObject
,SearchableModelObject
,SearchItem
,AccessControlled
,ModelObjectWithContextMenu
- Direct Known Subclasses:
AbstractCloudImpl
Node
s to dynamically expand/shrink the agents attached to Hudson.
Put another way, this class encapsulates different communication protocols needed to start a new agent programmatically.
Notes for implementers
Automatically delete idle agents
Nodes provisioned from a cloud do not automatically get released just because it's created fromCloud
.
Doing so requires a use of RetentionStrategy
. Instantiate your Slave
subtype with something
like CloudSlaveRetentionStrategy
so that it gets automatically deleted after some idle time.
Freeing an external resource when an agent is removed
Whether you do auto scale-down or not, you often want to release an external resource tied to a cloud-allocated agent when it is removed.
To do this, have your Slave
subtype remember the necessary handle (such as EC2 instance ID)
as a field. Such fields need to survive the user-initiated re-configuration of Slave
, so you'll need to
expose it in your Slave
configure-entries.jelly
and read it back in through DataBoundConstructor
.
You then implement your own Computer
subtype, override Slave.createComputer()
, and instantiate
your own Computer
subtype with this handle information.
Finally, override Computer.onRemoved()
and use the handle to talk to the "cloud" and de-allocate
the resource (such as shutting down a virtual machine.) Computer
needs to own this handle information
because by the time this happens, a Slave
object is already long gone.
Views
Since version 2.64, Jenkins clouds are visualized in UI. Implementations can providetop
or main
view
to be presented at the top of the page or at the bottom respectively. In the middle, actions have their summary
views displayed. Actions further contribute to sidepanel
with box
views. All mentioned views are
optional to preserve backward compatibility.- Author:
- Kohsuke Kawaguchi
- See Also:
-
Nested Class Summary
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
Modifier and TypeFieldDescriptionstatic final DescriptorList<Cloud>
Deprecated.Uniquely identifies thisCloud
instance among other instances inJenkins.clouds
.static final Permission
Permission constant to control mutation operations onCloud
. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic DescriptorExtensionList<Cloud,
Descriptor<Cloud>> all()
Returns all the registeredCloud
descriptors.boolean
canProvision
(Label label) Deprecated.UsecanProvision(CloudState)
instead.boolean
canProvision
(Cloud.CloudState state) Returns true if this cloud is capable of provisioning new nodes for the given label.org.kohsuke.stapler.HttpResponse
doConfigSubmit
(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp) Accepts the update to the node configuration.org.kohsuke.stapler.HttpResponse
Deletes the cloud.getACL()
Obtains the ACL associated with this object.Gets the descriptor for this instance.getIcon()
Returns the URL of this item relative to the parentSearchItem
.getUrl()
Get URL of the cloud.Deprecated.Useprovision(CloudState, int)
instead.provision
(Cloud.CloudState state, int excessWorkload) Provisions newNode
s from this cloud.reconfigure
(org.kohsuke.stapler.StaplerRequest2 req, net.sf.json.JSONObject form) reconfigure
(org.kohsuke.stapler.StaplerRequest req, net.sf.json.JSONObject form) Deprecated.static void
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
-
name
Uniquely identifies thisCloud
instance among other instances inJenkins.clouds
. This is expected to be short ID-like string that does not contain any character unsafe as variable name or URL path token. -
ALL
All registeredCloud
implementations. -
PROVISION
Permission constant to control mutation operations onCloud
. This includes provisioning a new node, as well as removing it.
-
-
Constructor Details
-
Cloud
-
-
Method Details
-
getDisplayName
- Specified by:
getDisplayName
in interfaceModelObject
-
getUrl
Get URL of the cloud.- Returns:
- Jenkins relative URL.
- Since:
- 2.64
-
getSearchUrl
Description copied from interface:SearchItem
Returns the URL of this item relative to the parentSearchItem
.- Specified by:
getSearchUrl
in interfaceSearchItem
- Returns:
- URL like "foo" or "foo/bar". The path can end with '/'. The path that starts with '/' will be interpreted as the absolute path (within the context path of Jenkins.)
-
getACL
Description copied from interface:AccessControlled
Obtains the ACL associated with this object.- Specified by:
getACL
in interfaceAccessControlled
- Returns:
- never null.
-
provision
@Deprecated public Collection<NodeProvisioner.PlannedNode> provision(Label label, int excessWorkload) Deprecated.Useprovision(CloudState, int)
instead.Provisions newNode
s from this cloud.NodeProvisioner
performs a trend analysis on the load, and when it determines that it really needs to bring up additional nodes, this method is invoked.The implementation of this method asynchronously starts node provisioning.
- Parameters:
label
- The label that indicates what kind of nodes are needed now. Newly launched node needs to have this label. Only thoseLabel
s that this instance returned true from thecanProvision(Label)
method will be passed here. This parameter is null if Hudson needs to provision a newNode
for jobs that don't have any tie to any label.excessWorkload
- Number of total executors needed to meet the current demand. Always ≥ 1. For example, if this is 3, the implementation should launch 3 agents with 1 executor each, or 1 agent with 3 executors, etc.- Returns:
NodeProvisioner.PlannedNode
s that represent asynchronousNode
provisioning operations. Can be empty but must not be null.NodeProvisioner
will be responsible for adding the resultingNode
s into Hudson viaJenkins.addNode(Node)
, so aCloud
implementation just needs to returnNodeProvisioner.PlannedNode
s that each contain an object that implementsFuture
. When theFuture
has completed its work,Future.get()
will be called to obtain the provisionedNode
object.
-
provision
public Collection<NodeProvisioner.PlannedNode> provision(Cloud.CloudState state, int excessWorkload) Provisions newNode
s from this cloud.NodeProvisioner
performs a trend analysis on the load, and when it determines that it really needs to bring up additional nodes, this method is invoked.The implementation of this method asynchronously starts node provisioning.
- Parameters:
state
- the current state.excessWorkload
- Number of total executors needed to meet the current demand. Always ≥ 1. For example, if this is 3, the implementation should launch 3 agents with 1 executor each, or 1 agent with 3 executors, etc.- Returns:
NodeProvisioner.PlannedNode
s that represent asynchronousNode
provisioning operations. Can be empty but must not be null.NodeProvisioner
will be responsible for adding the resultingNode
s into Hudson viaJenkins.addNode(Node)
, so aCloud
implementation just needs to returnNodeProvisioner.PlannedNode
s that each contain an object that implementsFuture
. When theFuture
has completed its work,Future.get()
will be called to obtain the provisionedNode
object.
-
canProvision
Deprecated.UsecanProvision(CloudState)
instead.Returns true if this cloud is capable of provisioning new nodes for the given label. -
canProvision
Returns true if this cloud is capable of provisioning new nodes for the given label. -
getDescriptor
Description copied from interface:Describable
Gets the descriptor for this instance.Descriptor
is a singleton for every concreteDescribable
implementation, so ifa.getClass() == b.getClass()
then by defaulta.getDescriptor() == b.getDescriptor()
as well. (In rare cases a single implementation class may be used for instances with distinct descriptors.)- Specified by:
getDescriptor
in interfaceDescribable<Cloud>
-
all
Returns all the registeredCloud
descriptors. -
registerPermissions
@Initializer(before=SYSTEM_CONFIG_LOADED) @Restricted(org.kohsuke.accmod.restrictions.DoNotUse.class) public static void registerPermissions() -
getIcon
-
getIconClassName
-
getIconAltText
-
doDoDelete
Deletes the cloud.- Throws:
IOException
-
doConfigSubmit
@POST public org.kohsuke.stapler.HttpResponse doConfigSubmit(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp) throws IOException, jakarta.servlet.ServletException, Descriptor.FormException Accepts the update to the node configuration.- Throws:
IOException
jakarta.servlet.ServletException
Descriptor.FormException
-
reconfigure
public Cloud reconfigure(@NonNull org.kohsuke.stapler.StaplerRequest2 req, net.sf.json.JSONObject form) throws Descriptor.FormException - Throws:
Descriptor.FormException
- Since:
- 2.475
-
reconfigure
@Deprecated public Cloud reconfigure(@NonNull org.kohsuke.stapler.StaplerRequest req, net.sf.json.JSONObject form) throws Descriptor.FormException Deprecated.- Throws:
Descriptor.FormException
-
all()
for read access, andExtension
for registration.