diff --git a/execution/theodolite.yaml b/execution/theodolite.yaml index c9fcf7e3f83621d352df0ad1ecf8905b2dd20d6d..1282531b5675cb294b335d692cf81b07b6bb2dd4 100644 --- a/execution/theodolite.yaml +++ b/execution/theodolite.yaml @@ -1,7 +1,7 @@ apiVersion: batch/v1 kind: Job metadata: - name: theodolite + name: bw-theodolite spec: template: spec: @@ -14,7 +14,7 @@ spec: - containerPort: 80 name: analysis - name: theodolite - image: ghcr.io/cau-se/theodolite:theodolite-kotlin-latest + image: benediktwetzel/theodolite-test #ghcr.io/cau-se/theodolite:theodolite-kotlin-latest imagePullPolicy: Always env: - name: NAMESPACE @@ -27,6 +27,10 @@ spec: value: /etc/benchmark/example-benchmark-yaml-resource.yaml - name: THEODOLITE_APP_RESOURCES value: /etc/app-resources + - name: RESULTS_FOLDER + value: results + - name: CREATE_RESULTS_FOLDER + value: "true" volumeMounts: - mountPath: "/deployments/results" name: theodolite-pv-storage diff --git a/theodolite-quarkus/src/main/docker/Dockerfile.jvm b/theodolite-quarkus/src/main/docker/Dockerfile.jvm index ebe10de1227bba566d4502f6deb97ab146be017b..6733d5d441e8292e02547cf59131c706575e9d86 100644 --- a/theodolite-quarkus/src/main/docker/Dockerfile.jvm +++ b/theodolite-quarkus/src/main/docker/Dockerfile.jvm @@ -33,8 +33,6 @@ RUN microdnf install curl ca-certificates ${JAVA_PACKAGE} \ && microdnf clean all \ && mkdir /deployments \ && chown 1001 /deployments \ - && mkdir deployments/results \ - && chown 777 deployments/results \ && chmod "g+rwX" /deployments \ && chown 1001:root /deployments \ && curl https://repo1.maven.org/maven2/io/fabric8/run-java-sh/${RUN_JAVA_VERSION}/run-java-sh-${RUN_JAVA_VERSION}-sh.sh -o /deployments/run-java.sh \ diff --git a/theodolite-quarkus/src/main/docker/Dockerfile.native b/theodolite-quarkus/src/main/docker/Dockerfile.native index 67d904d30f4a8873ace1f97dac9f37b3316a5440..29836a7148b573c3051c33341718b06008fa07e2 100644 --- a/theodolite-quarkus/src/main/docker/Dockerfile.native +++ b/theodolite-quarkus/src/main/docker/Dockerfile.native @@ -17,8 +17,6 @@ FROM registry.access.redhat.com/ubi8/ubi-minimal:8.3 WORKDIR /deployments RUN chown 1001 /deployments \ - && mkdir results \ - && chown 777 deployments/results \ && chmod "g+rwX" /deployments \ && chown 1001:root /deployments COPY --chown=1001:root build/*-runner /deployments/application diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/evaluation/AnalysisExecutor.kt b/theodolite-quarkus/src/main/kotlin/theodolite/evaluation/AnalysisExecutor.kt index ddf2c7b5c34aaf9fa3abfec8ad02bab830fefc35..8c74c73881e6c45d48a4197338d1a6eff6845e2f 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/evaluation/AnalysisExecutor.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/evaluation/AnalysisExecutor.kt @@ -41,7 +41,12 @@ class AnalysisExecutor( query = "sum by(group)(kafka_consumergroup_group_lag >= 0)" ) - CsvExporter().toCsv(name = "results/$executionId-${load.get()}-${res.get()}-${slo.sloType}", prom = prometheusData) + var resultsFolder: String = System.getenv("RESULTS_FOLDER") + if (resultsFolder.isNotEmpty()){ + resultsFolder += "/" + } + + CsvExporter().toCsv(name = "$resultsFolder$executionId-${load.get()}-${res.get()}-${slo.sloType}", prom = prometheusData) val sloChecker = SloCheckerFactory().create( sloType = slo.sloType, externalSlopeURL = slo.externalSloUrl, diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/execution/Shutdown.kt b/theodolite-quarkus/src/main/kotlin/theodolite/execution/Shutdown.kt index f5c0251c298dea0801dc601c1d2b790de465459e..a50a38e79b52a72fa68eb9eda70cf1072f80df74 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/execution/Shutdown.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/execution/Shutdown.kt @@ -5,6 +5,7 @@ import theodolite.benchmark.BenchmarkExecution import theodolite.benchmark.KubernetesBenchmark import theodolite.util.LoadDimension import theodolite.util.Resource +import java.lang.Exception private val logger = KotlinLogging.logger {} @@ -23,6 +24,7 @@ class Shutdown(private val benchmarkExecution: BenchmarkExecution, private val b */ override fun run() { // Build Configuration to teardown + try { logger.info { "Received shutdown signal -> Shutting down" } val deployment = benchmark.buildDeployment( @@ -30,8 +32,13 @@ class Shutdown(private val benchmarkExecution: BenchmarkExecution, private val b res = Resource(0, emptyList()), configurationOverrides = benchmarkExecution.configOverrides ) + deployment.teardown() + } catch (e: Exception) { + logger.warn { "Could not delete all specified resources from Kubernetes. " + + "This could be the case, if not all resources are deployed and running." } + + } logger.info { "Teardown everything deployed" } - deployment.teardown() logger.info { "Teardown completed" } } } diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/execution/TheodoliteExecutor.kt b/theodolite-quarkus/src/main/kotlin/theodolite/execution/TheodoliteExecutor.kt index e8008a0fd8dc4e2df3b146e81fb505f418025584..01ed386ac1af8d78aeeea6e79ca0dee3b2020dc7 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/execution/TheodoliteExecutor.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/execution/TheodoliteExecutor.kt @@ -1,6 +1,7 @@ package theodolite.execution import com.google.gson.GsonBuilder +import mu.KotlinLogging import theodolite.benchmark.BenchmarkExecution import theodolite.benchmark.KubernetesBenchmark import theodolite.patcher.PatcherDefinitionFactory @@ -10,9 +11,17 @@ import theodolite.util.Config import theodolite.util.LoadDimension import theodolite.util.Resource import theodolite.util.Results +import java.io.File import java.io.PrintWriter +import java.lang.IllegalArgumentException +import java.lang.Thread.sleep +import java.nio.file.Files +import java.nio.file.Path import java.time.Duration + +private val logger = KotlinLogging.logger {} + /** * The Theodolite executor runs all the experiments defined with the given execution and benchmark configuration. * @@ -92,13 +101,37 @@ class TheodoliteExecutor( return this.kubernetesBenchmark } + private fun getResultFolderString(): String { + var resultsFolder: String = System.getenv("RESULTS_FOLDER") + val createResultsFolder = System.getenv("CREATE_RESULTS_FOLDER") ?: "false" + + logger.info { "RESULT_FOLDER: $resultsFolder" } + + if (resultsFolder.isNotEmpty()){ + resultsFolder += "/" + } + + val directory = File(resultsFolder) + if (!directory.exists()) { + logger.error { "Folder $resultsFolder does not exist" } + if (createResultsFolder.toBoolean()) { + directory.mkdirs() + } else { + throw IllegalArgumentException("Result folder not found") + } + } + logger.info { "RESULT_FOLDER: $resultsFolder" } + return resultsFolder + } + /** * Run all experiments which are specified in the corresponding * execution and benchmark objects. */ fun run() { - storeAsFile(this.config, "results/${this.config.executionId}-execution-configuration") - storeAsFile(kubernetesBenchmark, "results/${this.config.executionId}-benchmark-configuration") + val resultsFolder = getResultFolderString() + storeAsFile(this.config, "$resultsFolder${this.config.executionId}-execution-configuration") + storeAsFile(kubernetesBenchmark, "$resultsFolder/${this.config.executionId}-benchmark-configuration") val config = buildConfig() // execute benchmarks for each load @@ -107,7 +140,7 @@ class TheodoliteExecutor( config.compositeStrategy.findSuitableResource(load, config.resources) } } - storeAsFile(config.compositeStrategy.benchmarkExecutor.results, "results/${this.config.executionId}-result") + storeAsFile(config.compositeStrategy.benchmarkExecutor.results, "$resultsFolder${this.config.executionId}-result") } private fun <T> storeAsFile(saveObject: T, filename: String) {