diff --git a/theodolite/crd/crd-benchmark.yaml b/theodolite/crd/crd-benchmark.yaml index 8fc7d08eef62ceb90b79328c3d55839bce81ecdd..529d1ea427a2867f290f360a7330ccabfaf4305f 100644 --- a/theodolite/crd/crd-benchmark.yaml +++ b/theodolite/crd/crd-benchmark.yaml @@ -87,7 +87,9 @@ spec: type: object properties: command: - type: string + type: array + items: + type: string afterActions: type: array default: [] @@ -111,7 +113,9 @@ spec: type: object properties: command: - type: string + type: array + items: + type: string 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. type: object @@ -172,7 +176,9 @@ spec: type: object properties: command: - type: string + type: array + items: + type: string afterActions: type: array default: [] @@ -196,7 +202,9 @@ spec: type: object properties: command: - type: string + type: array + items: + type: string 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. type: object @@ -257,7 +265,9 @@ spec: type: object properties: command: - type: string + type: array + items: + type: string afterActions: type: array default: [] @@ -281,7 +291,9 @@ spec: type: object properties: command: - type: string + type: array + items: + type: string 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. type: array diff --git a/theodolite/examples/operator/example-benchmark.yaml b/theodolite/examples/operator/example-benchmark.yaml index 3302ea8a83bff270a05cc9041d8d69b7904634ed..945a05b381565904e5b11e013975c9b2a321e9dc 100644 --- a/theodolite/examples/operator/example-benchmark.yaml +++ b/theodolite/examples/operator/example-benchmark.yaml @@ -19,9 +19,9 @@ spec: - selector: pod: matchLabels: - app: titan-ccp-aggregation + app: busybox1 exec: - command: "ls -l" # or list + command: ["rm", "test-folder"] loadGenerator: resources: - configMap: @@ -29,15 +29,7 @@ spec: files: - uc1-load-generator-service.yaml - uc1-load-generator-deployment.yaml - beforeActions: - - selector: - pod: - matchLabels: - 'app.kubernetes.io/name': grafana - - #container: "abc" # optional (if there is only one container or there exists something like a default container) - exec: - command: "kafka-topics.sh --create --topic abc" # or list + beforeActions: [] resourceTypes: - typeName: "Instances" patchers: diff --git a/theodolite/src/main/kotlin/theodolite/benchmark/Action.kt b/theodolite/src/main/kotlin/theodolite/benchmark/Action.kt index f6fac38d035759d11614db16a6ddd1fb6de58e14..9fff88eeaa813424a40e7351b7f2912c3f1f996a 100644 --- a/theodolite/src/main/kotlin/theodolite/benchmark/Action.kt +++ b/theodolite/src/main/kotlin/theodolite/benchmark/Action.kt @@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonInclude import com.fasterxml.jackson.databind.annotation.JsonDeserialize import io.fabric8.kubernetes.client.NamespacedKubernetesClient import io.quarkus.runtime.annotations.RegisterForReflection +import theodolite.util.ActionCommandFailedException @JsonDeserialize @RegisterForReflection @@ -14,12 +15,15 @@ class Action { lateinit var exec: Command fun exec(client: NamespacedKubernetesClient) { - ActionCommand(client = client) + val exitCode = ActionCommand(client = client) .exec( matchLabels = selector.pod.matchLabels, container = selector.container, command = exec.command - ) + ) + if(exitCode != 0){ + throw ActionCommandFailedException("Error while executing action, finished with exit code $exitCode") + } } } @@ -37,5 +41,5 @@ class PodSelector { @JsonDeserialize @RegisterForReflection class Command { - lateinit var command: String + lateinit var command: Array<String> } \ No newline at end of file diff --git a/theodolite/src/main/kotlin/theodolite/benchmark/ActionCommand.kt b/theodolite/src/main/kotlin/theodolite/benchmark/ActionCommand.kt index 3a846f7d1f8d4228515610a81066c805985c3b45..bceb456c0e83b8ff3453f1cd9d6ddd78b92e437e 100644 --- a/theodolite/src/main/kotlin/theodolite/benchmark/ActionCommand.kt +++ b/theodolite/src/main/kotlin/theodolite/benchmark/ActionCommand.kt @@ -27,9 +27,9 @@ class ActionCommand(val client: NamespacedKubernetesClient) { * `of any` of is used and the command is called on one of the possible pods. * @param container (Optional) The container to run the command. Is optional iff exactly one container exist. * @param command The command to be executed. - * @return + * @return the exit code of this executed command */ - fun exec(matchLabels: MutableMap<String, String>, command: String, container: String = ""): Int { + fun exec(matchLabels: MutableMap<String, String>, command: Array<String>, container: String = ""): Int { val exitCode = ExitCode() @@ -48,7 +48,7 @@ class ActionCommand(val client: NamespacedKubernetesClient) { .writingOutput(out) .writingError(error) .usingListener(MyPodExecListener(execLatch, exitCode)) - .exec(*command.split(" ").toTypedArray()) + .exec(*command) val latchTerminationStatus = execLatch.await(TIMEOUT, TimeUnit.SECONDS); if (!latchTerminationStatus) { @@ -60,7 +60,7 @@ class ActionCommand(val client: NamespacedKubernetesClient) { throw ActionCommandFailedException("Interrupted while waiting for the exec", e) } - logger.info { "Action command finished with code $exitCode" } + logger.info { "Action command finished with code ${exitCode.code}" } return exitCode.code } @@ -101,7 +101,7 @@ class ActionCommand(val client: NamespacedKubernetesClient) { override fun onFailure(throwable: Throwable, response: Response) { execLatch.countDown() - throw ActionCommandFailedException("Some error encountered while executing action") + throw ActionCommandFailedException("Some error encountered while executing action: ${throwable.printStackTrace()}") } override fun onClose(code: Int, reason: String) {