Class Cloud
- All Implemented Interfaces:
ExtensionPoint,Describable<Cloud>,ModelObject,SearchableModelObject,SearchItem,AccessControlled,ModelObjectWithContextMenu
- Direct Known Subclasses:
AbstractCloudImpl
Nodes 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 ClassesNested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudsonNested classes/interfaces inherited from interface jenkins.model.ModelObjectWithContextMenu
ModelObjectWithContextMenu.ContextMenu, ModelObjectWithContextMenu.ContextMenuVisibility, ModelObjectWithContextMenu.MenuItem, ModelObjectWithContextMenu.MenuItemType -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final DescriptorList<Cloud> Deprecated.Uniquely identifies thisCloudinstance among other instances inJenkins.clouds.static final PermissionPermission constant to control mutation operations onCloud. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic DescriptorExtensionList<Cloud, Descriptor<Cloud>> all()Returns all the registeredClouddescriptors.booleancanProvision(Label label) Deprecated.UsecanProvision(CloudState)instead.booleancanProvision(Cloud.CloudState state) Returns true if this cloud is capable of provisioning new nodes for the given label.org.kohsuke.stapler.HttpResponsedoConfigSubmit(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp) Accepts the update to the node configuration.org.kohsuke.stapler.HttpResponseDeletes 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 newNodes 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 voidMethods inherited from class hudson.model.Actionable
addAction, addOrReplaceAction, doContextMenu, doContextMenu, getAction, getAction, getActions, getActions, getAllActions, getDynamic, getDynamic, removeAction, removeActions, replaceAction, replaceActionsMethods 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, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface hudson.security.AccessControlled
checkAnyPermission, checkPermission, hasAnyPermission, hasPermission, hasPermission, hasPermission2Methods inherited from interface hudson.search.SearchItem
getSearchGroup, getSearchIcon
-
Field Details
-
name
Uniquely identifies thisCloudinstance 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 registeredCloudimplementations. -
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:
getDisplayNamein interfaceModelObject
-
getUrl
Get URL of the cloud.- Returns:
- Jenkins relative URL.
- Since:
- 2.64
-
getSearchUrl
Description copied from interface:SearchItemReturns the URL of this item relative to the parentSearchItem.- Specified by:
getSearchUrlin 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:AccessControlledObtains the ACL associated with this object.- Specified by:
getACLin interfaceAccessControlled- Returns:
- never null.
-
provision
@Deprecated public Collection<NodeProvisioner.PlannedNode> provision(Label label, int excessWorkload) Deprecated.Useprovision(CloudState, int)instead.Provisions newNodes from this cloud.NodeProvisionerperforms 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 thoseLabels that this instance returned true from thecanProvision(Label)method will be passed here. This parameter is null if Hudson needs to provision a newNodefor 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.PlannedNodes that represent asynchronousNodeprovisioning operations. Can be empty but must not be null.NodeProvisionerwill be responsible for adding the resultingNodes into Hudson viaJenkins.addNode(Node), so aCloudimplementation just needs to returnNodeProvisioner.PlannedNodes that each contain an object that implementsFuture. When theFuturehas completed its work,Future.get()will be called to obtain the provisionedNodeobject.
-
provision
public Collection<NodeProvisioner.PlannedNode> provision(Cloud.CloudState state, int excessWorkload) Provisions newNodes from this cloud.NodeProvisionerperforms 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.PlannedNodes that represent asynchronousNodeprovisioning operations. Can be empty but must not be null.NodeProvisionerwill be responsible for adding the resultingNodes into Hudson viaJenkins.addNode(Node), so aCloudimplementation just needs to returnNodeProvisioner.PlannedNodes that each contain an object that implementsFuture. When theFuturehas completed its work,Future.get()will be called to obtain the provisionedNodeobject.
-
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:DescribableGets the descriptor for this instance.Descriptoris a singleton for every concreteDescribableimplementation, 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.)By default looks for a nested class (conventionally named
DescriptorImpl) implementingDescriptorand marked withExtension.- Specified by:
getDescriptorin interfaceDescribable<Cloud>
-
all
Returns all the registeredClouddescriptors. -
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:
IOExceptionjakarta.servlet.ServletExceptionDescriptor.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, andExtensionfor registration.