Class EphemeralAgentKubernetesExecutionService
- java.lang.Object
-
- com.atlassian.bamboo.agent.ephemeral.EphemeralAgentKubernetesExecutionService
-
- All Implemented Interfaces:
EphemeralAgentExecutionService
public class EphemeralAgentKubernetesExecutionService extends Object implements EphemeralAgentExecutionService
-
-
Field Summary
Fields Modifier and Type Field Description protected CustomVariableContext
customVariableContext
static long
KUBERNETES_EXECUTOR_COMMAND_EXECUTION_TIMEOUT_VAL
static long
KUBERNETES_EXECUTOR_COMMAND_IDLE_TIMEOUT_VAL
static long
MAX_EPHEMERAL_AGENTS_LAUNCH_RETRIES_NUMBER_VAL
-
Constructor Summary
Constructors Constructor Description EphemeralAgentKubernetesExecutionService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clearNonActivePods()
Removes pods with completed Agent execution.@NotNull DeleteAgentPodsResult
deleteAllPods()
Deletes all ephemeral agent pods in any pod state.@NotNull DeleteAgentPodResult
deletePod(@NotNull String ephemeralAgentPodName)
Delete the pod with the requested name from the cluster if the one exists.@NotNull String
describePod(@NotNull String podName)
Describe pod details in human-readable way.protected KubernetesExecutor
getKubernetesExecutor()
@NotNull List<String>
getNamesOfPodsWithRunningAgent()
Gets names of pods with running agent container.@NotNull Optional<EphemeralAgentPod>
getPod(@NotNull String podName)
Get pod details@NotNull io.atlassian.fugue.Either<String,List<String>>
getPodContainerLogs(@NotNull String podName, @NotNull Optional<String> containerName, @NotNull Optional<Integer> resultsLimit, @NotNull Optional<String> afterTimestamp)
Gets either the whole pod or the particular pod container's logs.@NotNull List<EphemeralAgentPod>
getPods()
Get all pods.@NotNull LaunchAgentPodResult
launch(@NotNull EphemeralAgentTemplate ephemeralAgentTemplate, @NotNull CommonContext context)
Launch ephemeral agent based on delivered template and cotext.protected @NotNull String
randomizeName(@NotNull String rawName)
-
-
-
Field Detail
-
KUBERNETES_EXECUTOR_COMMAND_EXECUTION_TIMEOUT_VAL
public static final long KUBERNETES_EXECUTOR_COMMAND_EXECUTION_TIMEOUT_VAL
-
KUBERNETES_EXECUTOR_COMMAND_IDLE_TIMEOUT_VAL
public static final long KUBERNETES_EXECUTOR_COMMAND_IDLE_TIMEOUT_VAL
-
customVariableContext
@Inject protected CustomVariableContext customVariableContext
-
MAX_EPHEMERAL_AGENTS_LAUNCH_RETRIES_NUMBER_VAL
public static final long MAX_EPHEMERAL_AGENTS_LAUNCH_RETRIES_NUMBER_VAL
-
-
Method Detail
-
getKubernetesExecutor
protected KubernetesExecutor getKubernetesExecutor()
-
launch
@NotNull public @NotNull LaunchAgentPodResult launch(@NotNull @NotNull EphemeralAgentTemplate ephemeralAgentTemplate, @NotNull @NotNull CommonContext context)
Description copied from interface:EphemeralAgentExecutionService
Launch ephemeral agent based on delivered template and cotext.- Specified by:
launch
in interfaceEphemeralAgentExecutionService
- Parameters:
ephemeralAgentTemplate
- ephemeral configuration's templatecontext
- buildable context- Returns:
- result of agent launch
-
getPods
@NotNull public @NotNull List<EphemeralAgentPod> getPods()
Description copied from interface:EphemeralAgentExecutionService
Get all pods.- Specified by:
getPods
in interfaceEphemeralAgentExecutionService
- Returns:
- list of ephemeral agent pod instances
-
getPod
@NotNull public @NotNull Optional<EphemeralAgentPod> getPod(@NotNull @NotNull String podName)
Description copied from interface:EphemeralAgentExecutionService
Get pod details- Specified by:
getPod
in interfaceEphemeralAgentExecutionService
- Parameters:
podName
- pod name
-
describePod
@NotNull public @NotNull String describePod(@NotNull @NotNull String podName) throws KubernetesExecutorException
Description copied from interface:EphemeralAgentExecutionService
Describe pod details in human-readable way.- Specified by:
describePod
in interfaceEphemeralAgentExecutionService
- Parameters:
podName
- pod name- Throws:
KubernetesExecutorException
-
deletePod
@NotNull public @NotNull DeleteAgentPodResult deletePod(@NotNull @NotNull String ephemeralAgentPodName)
Description copied from interface:EphemeralAgentExecutionService
Delete the pod with the requested name from the cluster if the one exists.- Specified by:
deletePod
in interfaceEphemeralAgentExecutionService
- Parameters:
ephemeralAgentPodName
- unique across cluster pod name- Returns:
- result of agent pod removal
-
clearNonActivePods
public void clearNonActivePods()
Description copied from interface:EphemeralAgentExecutionService
Removes pods with completed Agent execution.- Specified by:
clearNonActivePods
in interfaceEphemeralAgentExecutionService
-
getPodContainerLogs
@NotNull public @NotNull io.atlassian.fugue.Either<String,List<String>> getPodContainerLogs(@NotNull @NotNull String podName, @NotNull @NotNull Optional<String> containerName, @NotNull @NotNull Optional<Integer> resultsLimit, @NotNull @NotNull Optional<String> afterTimestamp)
Description copied from interface:EphemeralAgentExecutionService
Gets either the whole pod or the particular pod container's logs. If the afterTimestamp is used, there must exist a log entry with this particular time stamp. Otherwise, an empty list will be returned.- Specified by:
getPodContainerLogs
in interfaceEphemeralAgentExecutionService
- Parameters:
podName
- ephemeral configuration's templatecontainerName
- optional name of the container, if empty the logs from the whole pod are requestedresultsLimit
- limit of logs lines, if empty all logs are fetchedafterTimestamp
- only log entries created after this timestamp will be taken- Returns:
- either error message if failed or list of log lines if successful
-
deleteAllPods
@NotNull public @NotNull DeleteAgentPodsResult deleteAllPods()
Description copied from interface:EphemeralAgentExecutionService
Deletes all ephemeral agent pods in any pod state.- Specified by:
deleteAllPods
in interfaceEphemeralAgentExecutionService
- Returns:
- result of pods removal
-
getNamesOfPodsWithRunningAgent
@NotNull public @NotNull List<String> getNamesOfPodsWithRunningAgent()
Description copied from interface:EphemeralAgentExecutionService
Gets names of pods with running agent container.- Specified by:
getNamesOfPodsWithRunningAgent
in interfaceEphemeralAgentExecutionService
- Returns:
- list of pod names if ephemeral agents are enabled, empty list otherwise
-
-