Skip to content
Snippets Groups Projects
Commit bb388751 authored by Benedikt Wetzel's avatar Benedikt Wetzel
Browse files

Make it possible to set the timeout for an action in the benchmark manifests

parent f643036f
No related branches found
No related tags found
1 merge request!201Introduce action commands
...@@ -90,6 +90,8 @@ spec: ...@@ -90,6 +90,8 @@ spec:
type: array type: array
items: items:
type: string type: string
timeout:
type: integer
afterActions: afterActions:
type: array type: array
default: [] default: []
...@@ -116,6 +118,8 @@ spec: ...@@ -116,6 +118,8 @@ spec:
type: array type: array
items: items:
type: string type: string
timeout:
type: integer
sut: sut:
description: The appResourceSets specifies all Kubernetes resources required to start the sut. A resourceSet can be either a configMap resourceSet or a fileSystem resourceSet. description: The appResourceSets specifies all Kubernetes resources required to start the sut. A resourceSet can be either a configMap resourceSet or a fileSystem resourceSet.
type: object type: object
...@@ -179,6 +183,8 @@ spec: ...@@ -179,6 +183,8 @@ spec:
type: array type: array
items: items:
type: string type: string
timeout:
type: integer
afterActions: afterActions:
type: array type: array
default: [] default: []
...@@ -205,6 +211,8 @@ spec: ...@@ -205,6 +211,8 @@ spec:
type: array type: array
items: items:
type: string type: string
timeout:
type: integer
loadGenerator: loadGenerator:
description: The loadGenResourceSets specifies all Kubernetes resources required to start the load generator. A resourceSet can be either a configMap resourceSet or a fileSystem resourceSet. description: The loadGenResourceSets specifies all Kubernetes resources required to start the load generator. A resourceSet can be either a configMap resourceSet or a fileSystem resourceSet.
type: object type: object
...@@ -268,6 +276,8 @@ spec: ...@@ -268,6 +276,8 @@ spec:
type: array type: array
items: items:
type: string type: string
timeout:
type: integer
afterActions: afterActions:
type: array type: array
default: [] default: []
...@@ -294,6 +304,8 @@ spec: ...@@ -294,6 +304,8 @@ spec:
type: array type: array
items: items:
type: string type: string
timeout:
type: integer
resourceTypes: resourceTypes:
description: A list of resource types that can be scaled for this `benchmark` resource. For each resource type the concrete values are defined in the `execution` object. description: A list of resource types that can be scaled for this `benchmark` resource. For each resource type the concrete values are defined in the `execution` object.
type: array type: array
......
...@@ -22,6 +22,7 @@ spec: ...@@ -22,6 +22,7 @@ spec:
app: busybox1 app: busybox1
exec: exec:
command: ["rm", "test-folder"] command: ["rm", "test-folder"]
timeout: 90
loadGenerator: loadGenerator:
resources: resources:
- configMap: - configMap:
......
...@@ -5,6 +5,7 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize ...@@ -5,6 +5,7 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize
import io.fabric8.kubernetes.client.NamespacedKubernetesClient import io.fabric8.kubernetes.client.NamespacedKubernetesClient
import io.quarkus.runtime.annotations.RegisterForReflection import io.quarkus.runtime.annotations.RegisterForReflection
import theodolite.util.ActionCommandFailedException import theodolite.util.ActionCommandFailedException
import theodolite.util.Configuration
@JsonDeserialize @JsonDeserialize
@RegisterForReflection @RegisterForReflection
...@@ -19,6 +20,7 @@ class Action { ...@@ -19,6 +20,7 @@ class Action {
.exec( .exec(
matchLabels = selector.pod.matchLabels, matchLabels = selector.pod.matchLabels,
container = selector.container, container = selector.container,
timeout = exec.timeout,
command = exec.command command = exec.command
) )
if(exitCode != 0){ if(exitCode != 0){
...@@ -42,4 +44,5 @@ class PodSelector { ...@@ -42,4 +44,5 @@ class PodSelector {
@RegisterForReflection @RegisterForReflection
class Command { class Command {
lateinit var command: Array<String> lateinit var command: Array<String>
var timeout: Long = Configuration.TIMEOUT
} }
\ No newline at end of file
...@@ -6,6 +6,7 @@ import io.fabric8.kubernetes.client.dsl.ExecWatch ...@@ -6,6 +6,7 @@ import io.fabric8.kubernetes.client.dsl.ExecWatch
import mu.KotlinLogging import mu.KotlinLogging
import okhttp3.Response import okhttp3.Response
import theodolite.util.ActionCommandFailedException import theodolite.util.ActionCommandFailedException
import theodolite.util.Configuration
import java.io.ByteArrayOutputStream import java.io.ByteArrayOutputStream
import java.time.Duration import java.time.Duration
import java.util.concurrent.CountDownLatch import java.util.concurrent.CountDownLatch
...@@ -13,7 +14,6 @@ import java.util.concurrent.TimeUnit ...@@ -13,7 +14,6 @@ import java.util.concurrent.TimeUnit
import kotlin.properties.Delegates import kotlin.properties.Delegates
private val logger = KotlinLogging.logger {} private val logger = KotlinLogging.logger {}
private const val TIMEOUT = 30L
class ActionCommand(val client: NamespacedKubernetesClient) { class ActionCommand(val client: NamespacedKubernetesClient) {
var out: ByteArrayOutputStream = ByteArrayOutputStream() var out: ByteArrayOutputStream = ByteArrayOutputStream()
...@@ -29,8 +29,12 @@ class ActionCommand(val client: NamespacedKubernetesClient) { ...@@ -29,8 +29,12 @@ class ActionCommand(val client: NamespacedKubernetesClient) {
* @param command The command to be executed. * @param command The command to be executed.
* @return the exit code of this executed command * @return the exit code of this executed command
*/ */
fun exec(matchLabels: MutableMap<String, String>, command: Array<String>, container: String = ""): Int { fun exec(
matchLabels: MutableMap<String, String>,
command: Array<String>,
timeout: Long = Configuration.TIMEOUT,
container: String = ""
): Int {
val exitCode = ExitCode() val exitCode = ExitCode()
try { try {
...@@ -50,7 +54,7 @@ class ActionCommand(val client: NamespacedKubernetesClient) { ...@@ -50,7 +54,7 @@ class ActionCommand(val client: NamespacedKubernetesClient) {
.usingListener(MyPodExecListener(execLatch, exitCode)) .usingListener(MyPodExecListener(execLatch, exitCode))
.exec(*command) .exec(*command)
val latchTerminationStatus = execLatch.await(TIMEOUT, TimeUnit.SECONDS); val latchTerminationStatus = execLatch.await(timeout, TimeUnit.SECONDS);
if (!latchTerminationStatus) { if (!latchTerminationStatus) {
throw ActionCommandFailedException("Latch could not terminate within specified time") throw ActionCommandFailedException("Latch could not terminate within specified time")
} }
......
...@@ -13,6 +13,11 @@ class Configuration( ...@@ -13,6 +13,11 @@ class Configuration(
val NAMESPACE = System.getenv("NAMESPACE") ?: DEFAULT_NAMESPACE val NAMESPACE = System.getenv("NAMESPACE") ?: DEFAULT_NAMESPACE
val COMPONENT_NAME = System.getenv("COMPONENT_NAME") ?: DEFAULT_COMPONENT_NAME val COMPONENT_NAME = System.getenv("COMPONENT_NAME") ?: DEFAULT_COMPONENT_NAME
val EXECUTION_MODE = System.getenv("MODE") ?: ExecutionModes.STANDALONE.value val EXECUTION_MODE = System.getenv("MODE") ?: ExecutionModes.STANDALONE.value
/**
* Specifies how long Theodolite should wait (in sec) before aborting the execution of an action command.
*/
const val TIMEOUT: Long = 30L
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment