Class SwarmAgentTemplate

java.lang.Object
hudson.model.AbstractDescribableImpl<SwarmAgentTemplate>
io.jenkins.plugins.swarmcloud.SwarmAgentTemplate
All Implemented Interfaces:
Describable<SwarmAgentTemplate>

public class SwarmAgentTemplate extends AbstractDescribableImpl<SwarmAgentTemplate>
Template for Docker Swarm agents. Defines the configuration for agent containers.
  • Constructor Details

    • SwarmAgentTemplate

      @DataBoundConstructor public SwarmAgentTemplate(@NonNull String name)
  • Method Details

    • readResolve

      protected Object readResolve()
      Ensures transient fields are initialized after deserialization.
    • getCurrentInstancesCounter

      public AtomicInteger getCurrentInstancesCounter()
      Gets the currentInstances counter, initializing if needed. Public for atomic operations from ClusterMonitor.
    • getName

      @NonNull public String getName()
    • getImage

      @NonNull public String getImage()
    • setImage

      @DataBoundSetter public void setImage(String image)
    • getLabelString

      @Nullable public String getLabelString()
    • setLabelString

      @DataBoundSetter public void setLabelString(String labelString)
    • getLabel

      @Nullable public String getLabel()
    • setLabel

      @DataBoundSetter public void setLabel(String label)
    • getEntrypoint

      @Nullable public String getEntrypoint()
    • setEntrypoint

      @DataBoundSetter public void setEntrypoint(String entrypoint)
    • getRemoteFs

      @NonNull public String getRemoteFs()
    • setRemoteFs

      @DataBoundSetter public void setRemoteFs(String remoteFs)
    • getWorkingDir

      @NonNull public String getWorkingDir()
    • setWorkingDir

      @DataBoundSetter public void setWorkingDir(String workingDir)
    • getNumExecutors

      public int getNumExecutors()
    • setNumExecutors

      @DataBoundSetter public void setNumExecutors(int numExecutors)
    • getMaxInstances

      public int getMaxInstances()
    • setMaxInstances

      @DataBoundSetter public void setMaxInstances(int maxInstances)
    • getMode

      @NonNull public Node.Mode getMode()
    • setMode

      @DataBoundSetter public void setMode(Node.Mode mode)
    • getCpuLimit

      @Nullable public String getCpuLimit()
    • setCpuLimit

      @DataBoundSetter public void setCpuLimit(String cpuLimit)
    • getMemoryLimit

      @Nullable public String getMemoryLimit()
    • setMemoryLimit

      @DataBoundSetter public void setMemoryLimit(String memoryLimit)
    • getLimitsNanoCPUs

      @Nullable public Long getLimitsNanoCPUs()
      Gets CPU limit in nanoCPUs (1e9 = 1 CPU). For docker-swarm-plugin compatibility.
    • setLimitsNanoCPUs

      @DataBoundSetter public void setLimitsNanoCPUs(Long nanoCPUs)
    • getLimitsMemoryBytes

      @Nullable public Long getLimitsMemoryBytes()
      Gets memory limit in bytes. For docker-swarm-plugin compatibility.
    • setLimitsMemoryBytes

      @DataBoundSetter public void setLimitsMemoryBytes(Long bytes)
    • getReservationsNanoCPUs

      @Nullable public Long getReservationsNanoCPUs()
      Gets CPU reservation in nanoCPUs. For docker-swarm-plugin compatibility.
    • setReservationsNanoCPUs

      @DataBoundSetter public void setReservationsNanoCPUs(Long nanoCPUs)
    • getReservationsMemoryBytes

      @Nullable public Long getReservationsMemoryBytes()
      Gets memory reservation in bytes. For docker-swarm-plugin compatibility.
    • setReservationsMemoryBytes

      @DataBoundSetter public void setReservationsMemoryBytes(Long bytes)
    • getCpuReservation

      @Nullable public String getCpuReservation()
    • setCpuReservation

      @DataBoundSetter public void setCpuReservation(String cpuReservation)
    • getMemoryReservation

      @Nullable public String getMemoryReservation()
    • setMemoryReservation

      @DataBoundSetter public void setMemoryReservation(String memoryReservation)
    • getMounts

      @NonNull public List<SwarmAgentTemplate.MountConfig> getMounts()
    • setMounts

      @DataBoundSetter public void setMounts(List<SwarmAgentTemplate.MountConfig> mounts)
    • getHostBinds

      @NonNull public List<SwarmAgentTemplate.MountConfig> getHostBinds()
    • setHostBinds

      @DataBoundSetter public void setHostBinds(List<SwarmAgentTemplate.MountConfig> hostBinds)
    • getEnvironmentVariables

      @NonNull public List<SwarmAgentTemplate.EnvironmentVariable> getEnvironmentVariables()
    • setEnvironmentVariables

      @DataBoundSetter public void setEnvironmentVariables(List<SwarmAgentTemplate.EnvironmentVariable> environmentVariables)
    • getEnvVars

      @NonNull public List<SwarmAgentTemplate.EnvironmentVariable> getEnvVars()
    • setEnvVars

      @DataBoundSetter public void setEnvVars(List<SwarmAgentTemplate.EnvironmentVariable> envVars)
    • getPlacementConstraints

      @NonNull public List<String> getPlacementConstraints()
    • setPlacementConstraints

      @DataBoundSetter public void setPlacementConstraints(List<String> placementConstraints)
    • setPlacementConstraintsString

      @DataBoundSetter public void setPlacementConstraintsString(String constraints)
      Sets placement constraints from a newline-separated string (for Jelly UI).
    • getPlacementConstraintsString

      @Nullable public String getPlacementConstraintsString()
      Gets placement constraints as a newline-separated string (for Jelly UI).
    • getNetworkAliases

      @NonNull public List<String> getNetworkAliases()
    • setNetworkAliases

      @DataBoundSetter public void setNetworkAliases(List<String> networkAliases)
    • setNetworkAliasesString

      @DataBoundSetter public void setNetworkAliasesString(String aliases)
      Sets network aliases from a comma-separated string (for Jelly UI).
    • getNetworkAliasesString

      @Nullable public String getNetworkAliasesString()
      Gets network aliases as a comma-separated string (for Jelly UI).
    • getSecrets

      @NonNull public List<SwarmSecretConfig> getSecrets()
    • setSecrets

      @DataBoundSetter public void setSecrets(List<SwarmSecretConfig> secrets)
    • getConfigs

      @NonNull public List<SwarmConfigFile> getConfigs()
    • setConfigs

      @DataBoundSetter public void setConfigs(List<SwarmConfigFile> configs)
    • getConfigsString

      @Nullable public String getConfigsString()
      Gets configs as newline-separated string for UI (format: configName:targetPath).
    • setConfigsString

      @DataBoundSetter public void setConfigsString(String configsStr)
      Sets configs from newline-separated string (format: configName:targetPath). Example: nethasp.ini:/opt/1cv8/current/conf/nethasp.ini
    • getCacheDirs

      @NonNull public List<String> getCacheDirs()
    • setCacheDirs

      @DataBoundSetter public void setCacheDirs(List<String> cacheDirs)
    • getCacheDirsString

      @Nullable public String getCacheDirsString()
      Gets cache directories as newline-separated string for UI.
    • setCacheDirsString

      @DataBoundSetter public void setCacheDirsString(String cacheDirsStr)
      Sets cache directories from newline-separated string.
    • getHealthCheckCommand

      @Nullable public String getHealthCheckCommand()
    • setHealthCheckCommand

      @DataBoundSetter public void setHealthCheckCommand(String healthCheckCommand)
    • getHealthCheckIntervalSeconds

      public int getHealthCheckIntervalSeconds()
    • setHealthCheckIntervalSeconds

      @DataBoundSetter public void setHealthCheckIntervalSeconds(int healthCheckIntervalSeconds)
    • getHealthCheckTimeoutSeconds

      public int getHealthCheckTimeoutSeconds()
    • setHealthCheckTimeoutSeconds

      @DataBoundSetter public void setHealthCheckTimeoutSeconds(int healthCheckTimeoutSeconds)
    • getHealthCheckRetries

      public int getHealthCheckRetries()
    • setHealthCheckRetries

      @DataBoundSetter public void setHealthCheckRetries(int healthCheckRetries)
    • hasHealthCheck

      public boolean hasHealthCheck()
      Checks if health check is configured.
    • getCapAdd

      @NonNull public List<String> getCapAdd()
    • setCapAdd

      @DataBoundSetter public void setCapAdd(List<String> capAdd)
    • setCapAddString

      @DataBoundSetter public void setCapAddString(String caps)
    • getCapAddString

      @Nullable public String getCapAddString()
    • getCapDrop

      @NonNull public List<String> getCapDrop()
    • setCapDrop

      @DataBoundSetter public void setCapDrop(List<String> capDrop)
    • setCapDropString

      @DataBoundSetter public void setCapDropString(String caps)
    • getCapDropString

      @Nullable public String getCapDropString()
    • getSysctls

      @NonNull public List<String> getSysctls()
    • setSysctls

      @DataBoundSetter public void setSysctls(List<String> sysctls)
    • setSysctlsString

      @DataBoundSetter public void setSysctlsString(String sysctlsStr)
    • getSysctlsString

      @Nullable public String getSysctlsString()
    • isPrivileged

      public boolean isPrivileged()
    • setPrivileged

      @DataBoundSetter public void setPrivileged(boolean privileged)
    • isOneShot

      public boolean isOneShot()
    • setOneShot

      @DataBoundSetter public void setOneShot(boolean oneShot)
    • isDisableContainerArgs

      public boolean isDisableContainerArgs()
      Returns true if container args should be disabled. When disabled, only environment variables are passed to the container.
    • setDisableContainerArgs

      @DataBoundSetter public void setDisableContainerArgs(boolean disableContainerArgs)
    • getUser

      @Nullable public String getUser()
    • setUser

      @DataBoundSetter public void setUser(String user)
    • getHostname

      @Nullable public String getHostname()
    • setHostname

      @DataBoundSetter public void setHostname(String hostname)
    • getDnsServers

      @NonNull public List<String> getDnsServers()
    • setDnsServers

      @DataBoundSetter public void setDnsServers(List<String> dnsServers)
    • setDnsServersString

      @DataBoundSetter public void setDnsServersString(String dns)
    • getDnsServersString

      @Nullable public String getDnsServersString()
    • getDnsIps

      @Nullable public String getDnsIps()
    • setDnsIps

      @DataBoundSetter public void setDnsIps(String dnsIps)
    • getDnsOptions

      @NonNull public List<String> getDnsOptions()
    • setDnsOptions

      @DataBoundSetter public void setDnsOptions(List<String> dnsOptions)
    • getDnsSearch

      @NonNull public List<String> getDnsSearch()
    • setDnsSearch

      @DataBoundSetter public void setDnsSearch(List<String> dnsSearch)
    • getExtraHosts

      @NonNull public List<String> getExtraHosts()
      Gets extra hosts entries for container's /etc/hosts file. Format: hostname:IP (e.g., myhost:192.168.1.1)
    • setExtraHosts

      @DataBoundSetter public void setExtraHosts(List<String> extraHosts)
    • setExtraHostsString

      @DataBoundSetter public void setExtraHostsString(String extraHostsStr)
      Sets extra hosts from a newline-separated string (for Jelly UI). Format: hostname:IP (one per line)
    • getExtraHostsString

      @Nullable public String getExtraHostsString()
      Gets extra hosts as a newline-separated string (for Jelly UI).
    • getStopSignal

      @Nullable public String getStopSignal()
    • setStopSignal

      @DataBoundSetter public void setStopSignal(String stopSignal)
    • getStopGracePeriod

      public long getStopGracePeriod()
    • setStopGracePeriod

      @DataBoundSetter public void setStopGracePeriod(long stopGracePeriod)
    • getInheritFrom

      @Nullable public String getInheritFrom()
    • setInheritFrom

      @DataBoundSetter public void setInheritFrom(String inheritFrom)
    • getGenericResources

      @NonNull public List<SwarmAgentTemplate.GenericResource> getGenericResources()
    • setGenericResources

      @DataBoundSetter public void setGenericResources(List<SwarmAgentTemplate.GenericResource> genericResources)
    • getGenericResourcesString

      @Nullable public String getGenericResourcesString()
      Gets generic resources as string for UI (comma-separated: NVIDIA-GPU=1, FPGA=2)
    • setGenericResourcesString

      @DataBoundSetter public void setGenericResourcesString(String str)
    • getSeccompProfile

      @Nullable public String getSeccompProfile()
    • setSeccompProfile

      @DataBoundSetter public void setSeccompProfile(String seccompProfile)
    • getApparmorProfile

      @Nullable public String getApparmorProfile()
    • setApparmorProfile

      @DataBoundSetter public void setApparmorProfile(String apparmorProfile)
    • getConnectionTimeoutSeconds

      public int getConnectionTimeoutSeconds()
    • setConnectionTimeoutSeconds

      @DataBoundSetter public void setConnectionTimeoutSeconds(int connectionTimeoutSeconds)
    • getIdleTimeoutMinutes

      public int getIdleTimeoutMinutes()
    • setIdleTimeoutMinutes

      @DataBoundSetter public void setIdleTimeoutMinutes(int idleTimeoutMinutes)
    • getProvisionRetryCount

      public int getProvisionRetryCount()
    • setProvisionRetryCount

      @DataBoundSetter public void setProvisionRetryCount(int provisionRetryCount)
    • getProvisionRetryDelayMs

      public long getProvisionRetryDelayMs()
    • setProvisionRetryDelayMs

      @DataBoundSetter public void setProvisionRetryDelayMs(long provisionRetryDelayMs)
    • getPortBindings

      @NonNull public List<SwarmAgentTemplate.PortBinding> getPortBindings()
    • setPortBindings

      @DataBoundSetter public void setPortBindings(List<SwarmAgentTemplate.PortBinding> portBindings)
    • getPortBindingsString

      @Nullable public String getPortBindingsString()
      Gets port bindings as newline-separated string for UI. Format: [hostPort:]containerPort[/protocol] Examples: 80:8080, :5900, 443:8443/tcp
    • setPortBindingsString

      @DataBoundSetter public void setPortBindingsString(String str)
      Sets port bindings from newline-separated string.
    • getPortBinds

      @Nullable public String getPortBinds()
    • setPortBinds

      @DataBoundSetter public void setPortBinds(String portBinds)
    • getRegistryCredentialsId

      @Nullable public String getRegistryCredentialsId()
      Gets the credentials ID for Docker registry authentication. Used when pulling private images.
    • setRegistryCredentialsId

      @DataBoundSetter public void setRegistryCredentialsId(String registryCredentialsId)
      Sets the credentials ID for Docker registry authentication.
      Parameters:
      registryCredentialsId - ID of username/password credentials for registry auth
    • resolve

      @NonNull public SwarmAgentTemplate resolve()
      Resolves this template by merging with its parent template if inheritFrom is set. Similar to Kubernetes plugin podTemplate inheritance.

      Inheritance is resolved recursively, so multi-level chains (base <- mid <- leaf) merge the whole ancestor chain, with descendant values taking precedence over ancestors. Cyclic chains are detected and stopped to avoid infinite recursion.

      Returns:
      Resolved template with inherited values
    • setParent

      public void setParent(SwarmCloud parent)
    • getParent

      @Nullable public SwarmCloud getParent()
    • getLabelSet

      @NonNull public Set<LabelAtom> getLabelSet()
      Gets the set of labels for this template.
    • matches

      public boolean matches(@Nullable Label label)
      Checks if this template matches the given label.

      Matching is performed against the resolved template so that labels inherited through inheritFrom are honoured, keeping selection consistent with the configuration that is actually provisioned.

      A template that carries no label (neither its own nor an inherited one) only matches label-less jobs. It must not act as a catch-all for jobs that require a specific label — otherwise base templates kept solely for inheritance would be picked and provision agents that cannot run the queued job, producing a storm of unused nodes.

    • generateAgentName

      @NonNull public String generateAgentName()
      Generates a unique agent name.
    • getAvailableCapacity

      public int getAvailableCapacity()
      Gets the available capacity for new instances.
    • incrementInstances

      public void incrementInstances()
      Increments the current instance count.
    • decrementInstances

      public void decrementInstances()
      Decrements the current instance count.
    • getCurrentInstances

      public int getCurrentInstances()
      Gets the current instance count.
    • setCurrentInstances

      public void setCurrentInstances(int count)
      Sets the current instance count directly. Used for synchronizing with actual service count from Docker Swarm.