diff --git a/helm/values.yaml b/helm/values.yaml index c45e62aed8126a8b9f20a6dd0ca6083cd162bc2b..6c20f4bab35825e66412381b454df5c9dedec0fc 100644 --- a/helm/values.yaml +++ b/helm/values.yaml @@ -155,7 +155,10 @@ cp-helm-charts: ### kafka-lag-exporter: enabled: true + image: + pullPolicy: IfNotPresent nodeSelector: {} + clusters: - name: "theodolite-cp-kafka" bootstrapBrokers: "theodolite-cp-kafka:9092" diff --git a/theodolite/crd/crd-execution.yaml b/theodolite/crd/crd-execution.yaml index 47d0306f5150a8126f021c40bf3c4a4ce0e1abb1..d9cd41903bb2fdc18bd6640bdbe2eb764b2106ab 100644 --- a/theodolite/crd/crd-execution.yaml +++ b/theodolite/crd/crd-execution.yaml @@ -51,7 +51,7 @@ spec: description: The type of the resource. It must match one of the resource types specified in the referenced benchmark. type: string resourceValues: - descriptoin: List of resource values for the specified resource type. + description: List of resource values for the specified resource type. type: array items: type: integer diff --git a/theodolite/examples/operator/example-benchmark.yaml b/theodolite/examples/operator/example-benchmark.yaml index 2bd75f3299f3504a6d156c185162acad7e19b8cf..0950b2bdc14c3f43c18c853f1c0e56154fde6452 100644 --- a/theodolite/examples/operator/example-benchmark.yaml +++ b/theodolite/examples/operator/example-benchmark.yaml @@ -32,4 +32,4 @@ spec: numPartitions: 40 replicationFactor: 1 - name: "theodolite-.*" - removeOnly: True \ No newline at end of file + removeOnly: True diff --git a/theodolite/src/main/kotlin/theodolite/evaluation/AnalysisExecutor.kt b/theodolite/src/main/kotlin/theodolite/evaluation/AnalysisExecutor.kt index 777ea1c0ed43ac3af244dc0aaf770c69c11718cf..a7fe55ec35442b42c48499fa9d697e1491ca06d9 100644 --- a/theodolite/src/main/kotlin/theodolite/evaluation/AnalysisExecutor.kt +++ b/theodolite/src/main/kotlin/theodolite/evaluation/AnalysisExecutor.kt @@ -2,6 +2,7 @@ package theodolite.evaluation import mu.KotlinLogging import theodolite.benchmark.BenchmarkExecution +import theodolite.util.EvaluationFailedException import theodolite.util.IOHandler import theodolite.util.LoadDimension import theodolite.util.Resource @@ -37,7 +38,7 @@ class AnalysisExecutor( * @return true if the experiment succeeded. */ fun analyze(load: LoadDimension, res: Resource, executionIntervals: List<Pair<Instant, Instant>>): Boolean { - var result = false + var result: Boolean var repetitionCounter = 1 try { @@ -71,8 +72,7 @@ class AnalysisExecutor( result = sloChecker.evaluate(prometheusData) } catch (e: Exception) { - // TODO(throw exception in order to make it possible to mark an experiment as unsuccessfully) - logger.error { "Evaluation failed for resource '${res.get()}' and load '${load.get()}'. Error: $e" } + throw EvaluationFailedException("Evaluation failed for resource '${res.get()}' and load '${load.get()} ", e) } return result } diff --git a/theodolite/src/main/kotlin/theodolite/evaluation/MetricFetcher.kt b/theodolite/src/main/kotlin/theodolite/evaluation/MetricFetcher.kt index 833d7d1e16c2fbc91b58817b319a7d02af7f5b2b..e54d79fe0f95b9f6079bd4295a74e81250b73a90 100644 --- a/theodolite/src/main/kotlin/theodolite/evaluation/MetricFetcher.kt +++ b/theodolite/src/main/kotlin/theodolite/evaluation/MetricFetcher.kt @@ -53,8 +53,7 @@ class MetricFetcher(private val prometheusURL: String, private val offset: Durat } else { val values = parseValues(response) if (values.data?.result.isNullOrEmpty()) { - logger.error { "Empty query result: $values between $start and $end for query $query." } - throw NoSuchFieldException() + throw NoSuchFieldException("Empty query result: $values between $start and $end for query $query.") } return parseValues(response) } diff --git a/theodolite/src/main/kotlin/theodolite/execution/BenchmarkExecutor.kt b/theodolite/src/main/kotlin/theodolite/execution/BenchmarkExecutor.kt index e7b511d8c83b5abccece1204aad2a4a9ecfdfd26..fcc0f3b728ac368ca061d7b0acdc0ffde53398b9 100644 --- a/theodolite/src/main/kotlin/theodolite/execution/BenchmarkExecutor.kt +++ b/theodolite/src/main/kotlin/theodolite/execution/BenchmarkExecutor.kt @@ -29,7 +29,8 @@ abstract class BenchmarkExecutor( val repetitions: Int, val executionId: Int, val loadGenerationDelay: Long, - val afterTeardownDelay: Long + val afterTeardownDelay: Long, + val executionName: String ) { var run: AtomicBoolean = AtomicBoolean(true) diff --git a/theodolite/src/main/kotlin/theodolite/execution/BenchmarkExecutorImpl.kt b/theodolite/src/main/kotlin/theodolite/execution/BenchmarkExecutorImpl.kt index c54d1878d4957a0b8ec6a8fdfb18ec6342d7bfc1..f5f66de96e85dc937e2b4451142ec7327ec633e2 100644 --- a/theodolite/src/main/kotlin/theodolite/execution/BenchmarkExecutorImpl.kt +++ b/theodolite/src/main/kotlin/theodolite/execution/BenchmarkExecutorImpl.kt @@ -5,10 +5,8 @@ import mu.KotlinLogging import theodolite.benchmark.Benchmark import theodolite.benchmark.BenchmarkExecution import theodolite.evaluation.AnalysisExecutor -import theodolite.util.ConfigurationOverride -import theodolite.util.LoadDimension -import theodolite.util.Resource -import theodolite.util.Results +import theodolite.execution.operator.EventCreator +import theodolite.util.* import java.time.Duration import java.time.Instant @@ -24,7 +22,8 @@ class BenchmarkExecutorImpl( repetitions: Int, executionId: Int, loadGenerationDelay: Long, - afterTeardownDelay: Long + afterTeardownDelay: Long, + executionName: String ) : BenchmarkExecutor( benchmark, results, @@ -34,15 +33,19 @@ class BenchmarkExecutorImpl( repetitions, executionId, loadGenerationDelay, - afterTeardownDelay + afterTeardownDelay, + executionName ) { + private val eventCreator = EventCreator() + private val mode = Configuration.EXECUTION_MODE + override fun runExperiment(load: LoadDimension, res: Resource): Boolean { var result = false val executionIntervals: MutableList<Pair<Instant, Instant>> = ArrayList() for (i in 1.rangeTo(repetitions)) { - logger.info { "Run repetition $i/$repetitions" } if (this.run.get()) { + logger.info { "Run repetition $i/$repetitions" } executionIntervals.add(runSingleExperiment(load, res)) } else { break @@ -61,6 +64,11 @@ class BenchmarkExecutorImpl( ) this.results.setResult(Pair(load, res), result) } + + if(!this.run.get()) { + throw ExecutionFailedException("The execution was interrupted") + } + return result } @@ -73,22 +81,49 @@ class BenchmarkExecutorImpl( this.afterTeardownDelay ) val from = Instant.now() - // TODO(restructure try catch in order to throw exceptions if there are significant problems by running a experiment) + try { benchmarkDeployment.setup() this.waitAndLog() + if (mode == ExecutionModes.OPERATOR.value) { + eventCreator.createEvent( + executionName = executionName, + type = "NORMAL", + reason = "Start experiment", + message = "load: ${load.get()}, resources: ${res.get()}") + } } catch (e: Exception) { - logger.error { "Error while setup experiment." } - logger.error { "Error is: $e" } this.run.set(false) + + if (mode == ExecutionModes.OPERATOR.value) { + eventCreator.createEvent( + executionName = executionName, + type = "WARNING", + reason = "Start experiment failed", + message = "load: ${load.get()}, resources: ${res.get()}") + } + throw ExecutionFailedException("Error during setup the experiment", e) } val to = Instant.now() try { benchmarkDeployment.teardown() + if (mode == ExecutionModes.OPERATOR.value) { + eventCreator.createEvent( + executionName = executionName, + type = "NORMAL", + reason = "Stop experiment", + message = "Teardown complete") + } } catch (e: Exception) { - logger.warn { "Error while tearing down the benchmark deployment." } - logger.debug { "Teardown failed, caused by: $e" } + if (mode == ExecutionModes.OPERATOR.value) { + eventCreator.createEvent( + executionName = executionName, + type = "WARNING", + reason = "Stop experiment failed", + message = "Teardown failed: ${e.message}") + } + throw ExecutionFailedException("Error during teardown the experiment", e) } return Pair(from, to) } -} +} \ No newline at end of file diff --git a/theodolite/src/main/kotlin/theodolite/execution/ExecutionModes.kt b/theodolite/src/main/kotlin/theodolite/execution/ExecutionModes.kt new file mode 100644 index 0000000000000000000000000000000000000000..bf947be01b534fd000d3967f0b72ef25978d4110 --- /dev/null +++ b/theodolite/src/main/kotlin/theodolite/execution/ExecutionModes.kt @@ -0,0 +1,7 @@ +package theodolite.execution + +enum class ExecutionModes(val value: String) { + OPERATOR("operator"), + YAML_EXECUTOR("yaml-executor"), + STANDALONE("standalone") +} \ No newline at end of file diff --git a/theodolite/src/main/kotlin/theodolite/execution/Main.kt b/theodolite/src/main/kotlin/theodolite/execution/Main.kt index 7d5fca859422a194e81468d9766a9e7ba29fb998..11f696ddd739e987e92ecec724390948714d898b 100644 --- a/theodolite/src/main/kotlin/theodolite/execution/Main.kt +++ b/theodolite/src/main/kotlin/theodolite/execution/Main.kt @@ -3,6 +3,7 @@ package theodolite.execution import io.quarkus.runtime.annotations.QuarkusMain import mu.KotlinLogging import theodolite.execution.operator.TheodoliteOperator +import theodolite.util.Configuration import kotlin.system.exitProcess private val logger = KotlinLogging.logger {} @@ -13,13 +14,12 @@ object Main { @JvmStatic fun main(args: Array<String>) { - val mode = System.getenv("MODE") ?: "standalone" + val mode = Configuration.EXECUTION_MODE logger.info { "Start Theodolite with mode $mode" } - when (mode) { - "standalone" -> TheodoliteStandalone().start() - "yaml-executor" -> TheodoliteStandalone().start() // TODO remove (#209) - "operator" -> TheodoliteOperator().start() + when (mode.toLowerCase()) { + ExecutionModes.STANDALONE.value, ExecutionModes.YAML_EXECUTOR.value -> TheodoliteStandalone().start() // TODO remove standalone (#209) + ExecutionModes.OPERATOR.value -> TheodoliteOperator().start() else -> { logger.error { "MODE $mode not found" } exitProcess(1) diff --git a/theodolite/src/main/kotlin/theodolite/execution/Shutdown.kt b/theodolite/src/main/kotlin/theodolite/execution/Shutdown.kt index e795ada3e3bcb2dba19f1e088f426f38a824f4a7..6dedc94af864269d7d15929c69ec54aa384fc8e3 100644 --- a/theodolite/src/main/kotlin/theodolite/execution/Shutdown.kt +++ b/theodolite/src/main/kotlin/theodolite/execution/Shutdown.kt @@ -34,16 +34,15 @@ class Shutdown(private val benchmarkExecution: BenchmarkExecution, private val b afterTeardownDelay = 5L ) deployment.teardown() + logger.info { + "Finished teardown of all benchmark resources." + } } catch (e: Exception) { - // TODO(throw exception in order to make it possible to mark an experiment as unsuccessfully) 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 { - "Finished teardown of all benchmark resources." - } } } diff --git a/theodolite/src/main/kotlin/theodolite/execution/TheodoliteExecutor.kt b/theodolite/src/main/kotlin/theodolite/execution/TheodoliteExecutor.kt index addf30acde31ee8e3e53c20a5e2b57a03587d08e..fc312888131a35f3004c37df228cebebce16530f 100644 --- a/theodolite/src/main/kotlin/theodolite/execution/TheodoliteExecutor.kt +++ b/theodolite/src/main/kotlin/theodolite/execution/TheodoliteExecutor.kt @@ -65,7 +65,8 @@ class TheodoliteExecutor( repetitions = config.execution.repetitions, executionId = config.executionId, loadGenerationDelay = config.execution.loadGenerationDelay, - afterTeardownDelay = config.execution.afterTeardownDelay + afterTeardownDelay = config.execution.afterTeardownDelay, + executionName = config.name ) if (config.load.loadValues != config.load.loadValues.sorted()) { @@ -123,15 +124,18 @@ class TheodoliteExecutor( val config = buildConfig() // execute benchmarks for each load - for (load in config.loads) { - if (executor.run.get()) { - config.compositeStrategy.findSuitableResource(load, config.resources) + try { + for (load in config.loads) { + if (executor.run.get()) { + config.compositeStrategy.findSuitableResource(load, config.resources) + } } + } finally { + ioHandler.writeToJSONFile( + config.compositeStrategy.benchmarkExecutor.results, + "${resultsFolder}exp${this.config.executionId}-result" + ) } - ioHandler.writeToJSONFile( - config.compositeStrategy.benchmarkExecutor.results, - "${resultsFolder}exp${this.config.executionId}-result" - ) } private fun getAndIncrementExecutionID(fileURL: String): Int { diff --git a/theodolite/src/main/kotlin/theodolite/execution/TheodoliteStandalone.kt b/theodolite/src/main/kotlin/theodolite/execution/TheodoliteStandalone.kt index 76fd7f707a3e190ff6c61052ae4b5aaf50459418..1160132fdc4a7130a05861d72c5f688f0fb5af9b 100644 --- a/theodolite/src/main/kotlin/theodolite/execution/TheodoliteStandalone.kt +++ b/theodolite/src/main/kotlin/theodolite/execution/TheodoliteStandalone.kt @@ -3,6 +3,8 @@ package theodolite.execution import mu.KotlinLogging import theodolite.benchmark.BenchmarkExecution import theodolite.benchmark.KubernetesBenchmark +import theodolite.util.EvaluationFailedException +import theodolite.util.ExecutionFailedException import theodolite.util.YamlParser import kotlin.concurrent.thread import kotlin.system.exitProcess @@ -49,8 +51,14 @@ class TheodoliteStandalone { val shutdown = thread(start = false) { Shutdown(benchmarkExecution, benchmark).run() } Runtime.getRuntime().addShutdownHook(shutdown) - val executor = TheodoliteExecutor(benchmarkExecution, benchmark) - executor.run() + try { + TheodoliteExecutor(benchmarkExecution, benchmark).run() + } catch (e: EvaluationFailedException) { + logger.error { "Evaluation failed with error: ${e.message}" } + }catch (e: ExecutionFailedException) { + logger.error { "Execution failed with error: ${e.message}" } + } + logger.info { "Theodolite finished" } Runtime.getRuntime().removeShutdownHook(shutdown) exitProcess(0) diff --git a/theodolite/src/main/kotlin/theodolite/execution/operator/ClusterSetup.kt b/theodolite/src/main/kotlin/theodolite/execution/operator/ClusterSetup.kt index c3a2b7b25ed71e797c45d8b497bad6cad15e21e8..6987372f96a6d956378a928011be9b5406590a16 100644 --- a/theodolite/src/main/kotlin/theodolite/execution/operator/ClusterSetup.kt +++ b/theodolite/src/main/kotlin/theodolite/execution/operator/ClusterSetup.kt @@ -54,11 +54,8 @@ class ClusterSetup( benchmark.spec.name = benchmark.metadata.name Shutdown(execution.spec, benchmark.spec).start() } else { - logger.error { - "Execution with state ${States.RUNNING.value} was found, but no corresponding benchmark. " + - "Could not initialize cluster." - } - throw IllegalStateException("Cluster state is invalid, required Benchmark for running execution not found.") + throw IllegalStateException("Execution with state ${States.RUNNING.value} was found, but no corresponding benchmark. " + + "Could not initialize cluster.") } } } diff --git a/theodolite/src/main/kotlin/theodolite/execution/operator/EventCreator.kt b/theodolite/src/main/kotlin/theodolite/execution/operator/EventCreator.kt new file mode 100644 index 0000000000000000000000000000000000000000..fab098ebd5fe765a455d787ddb7fcbfbb6c9ffc7 --- /dev/null +++ b/theodolite/src/main/kotlin/theodolite/execution/operator/EventCreator.kt @@ -0,0 +1,60 @@ +package theodolite.execution.operator + +import io.fabric8.kubernetes.api.model.EventBuilder +import io.fabric8.kubernetes.api.model.EventSource +import io.fabric8.kubernetes.api.model.ObjectReference +import io.fabric8.kubernetes.client.DefaultKubernetesClient +import io.fabric8.kubernetes.client.NamespacedKubernetesClient +import mu.KotlinLogging +import theodolite.util.Configuration +import java.time.Instant +import java.util.* +import kotlin.NoSuchElementException +private val logger = KotlinLogging.logger {} + +class EventCreator { + val client: NamespacedKubernetesClient = DefaultKubernetesClient().inNamespace(Configuration.NAMESPACE) + + fun createEvent(executionName: String, type: String, message: String, reason: String) { + val uuid = UUID.randomUUID().toString() + try { + val objectRef = buildObjectReference(executionName) + val event = EventBuilder() + .withNewMetadata() + .withName(uuid) + .endMetadata() + .withMessage(message) + .withReason(reason) + .withType(type) + .withFirstTimestamp(Instant.now().toString()) // TODO change datetime format + .build() + + val source = EventSource() + source.component = Configuration.COMPONENT_NAME + event.source = source + + event.involvedObject = objectRef + client.v1().events().inNamespace(Configuration.NAMESPACE).createOrReplace(event) + } catch (e: NoSuchElementException) { + logger.warn {"Could not create event: type: $type, message: $message, reason: $reason, no corresponding execution found."} + } + } + + private fun buildObjectReference(executionName: String): ObjectReference { + val exec = TheodoliteOperator() + .getExecutionClient(client = client) + .list() + .items + .first{it.metadata.name == executionName} + + val objectRef = ObjectReference() + objectRef.apiVersion = exec.apiVersion + objectRef.kind = exec.kind + objectRef.uid = exec.metadata.uid + objectRef.name = exec.metadata.name + objectRef.namespace = exec.metadata.namespace + objectRef.resourceVersion = exec.metadata.resourceVersion + + return objectRef + } +} \ No newline at end of file diff --git a/theodolite/src/main/kotlin/theodolite/execution/operator/TheodoliteController.kt b/theodolite/src/main/kotlin/theodolite/execution/operator/TheodoliteController.kt index eb51a445ee05f1811a8780ff64c570f0bbdff4d0..3f8fe1495e88a08a99710b1b360fb8c392b0aacb 100644 --- a/theodolite/src/main/kotlin/theodolite/execution/operator/TheodoliteController.kt +++ b/theodolite/src/main/kotlin/theodolite/execution/operator/TheodoliteController.kt @@ -5,9 +5,11 @@ import io.fabric8.kubernetes.client.dsl.Resource import mu.KotlinLogging import theodolite.benchmark.BenchmarkExecution import theodolite.benchmark.KubernetesBenchmark +import theodolite.execution.ExecutionModes import theodolite.execution.TheodoliteExecutor import theodolite.model.crd.* import theodolite.patcher.ConfigOverrideModifier +import theodolite.util.ExecutionFailedException import theodolite.util.ExecutionStateComparator import java.lang.Thread.sleep @@ -93,9 +95,18 @@ class TheodoliteController( States.RUNNING -> { executionStateHandler.setExecutionState(execution.name, States.FINISHED) logger.info { "Execution of ${execution.name} is finally stopped." } + } + else -> { + executionStateHandler.setExecutionState(execution.name, States.FAILURE) + logger.warn { "Unexpected execution state, set state to ${States.FAILURE.value}" } } } } catch (e: Exception) { + EventCreator().createEvent( + executionName = execution.name, + type = "WARNING", + reason = "Execution failed", + message = "An error occurs while executing: ${e.message}") logger.error { "Failure while executing execution ${execution.name} with benchmark ${benchmark.name}." } logger.error { "Problem is: $e" } executionStateHandler.setExecutionState(execution.name, States.FAILURE) diff --git a/theodolite/src/main/kotlin/theodolite/execution/operator/TheodoliteOperator.kt b/theodolite/src/main/kotlin/theodolite/execution/operator/TheodoliteOperator.kt index 2aaba77c03884d94c4d5745db270e84324482878..cbce5749f39577a5e99bb773eff9ff8a3541ad8b 100644 --- a/theodolite/src/main/kotlin/theodolite/execution/operator/TheodoliteOperator.kt +++ b/theodolite/src/main/kotlin/theodolite/execution/operator/TheodoliteOperator.kt @@ -11,6 +11,7 @@ import theodolite.model.crd.BenchmarkCRD import theodolite.model.crd.BenchmarkExecutionList import theodolite.model.crd.ExecutionCRD import theodolite.model.crd.KubernetesBenchmarkList +import theodolite.util.Configuration private const val DEFAULT_NAMESPACE = "default" @@ -27,7 +28,7 @@ private val logger = KotlinLogging.logger {} * **See Also:** [Kubernetes Operator Pattern](https://kubernetes.io/docs/concepts/extend-kubernetes/operator/) */ class TheodoliteOperator { - private val namespace = System.getenv("NAMESPACE") ?: DEFAULT_NAMESPACE + private val namespace = Configuration.NAMESPACE private val client: NamespacedKubernetesClient = DefaultKubernetesClient().inNamespace(namespace) private lateinit var controller: TheodoliteController @@ -37,7 +38,7 @@ class TheodoliteOperator { fun start() { LeaderElector( client = client, - name = "theodolite-operator" // TODO(make leaslock name configurable via env var) + name = Configuration.COMPONENT_NAME ) .getLeadership(::startOperator) } @@ -115,7 +116,7 @@ class TheodoliteOperator { return this.controller } - private fun getExecutionClient(client: NamespacedKubernetesClient): MixedOperation< + fun getExecutionClient(client: NamespacedKubernetesClient): MixedOperation< ExecutionCRD, BenchmarkExecutionList, Resource<ExecutionCRD>> { diff --git a/theodolite/src/main/kotlin/theodolite/k8s/CustomResourceWrapper.kt b/theodolite/src/main/kotlin/theodolite/k8s/CustomResourceWrapper.kt index ab355677ec53216072fb58a170610aa5f12dba28..dd416ccd90166fa570aad2f9ed8095e6a20dea02 100644 --- a/theodolite/src/main/kotlin/theodolite/k8s/CustomResourceWrapper.kt +++ b/theodolite/src/main/kotlin/theodolite/k8s/CustomResourceWrapper.kt @@ -33,7 +33,7 @@ class CustomResourceWrapper( client.customResource(this.context) .delete(client.configuration.namespace, this.getName()) } catch (e: Exception) { - logger.warn { "Could not delete service monitor" } + logger.warn { "Could not delete custom resource" } } } diff --git a/theodolite/src/main/kotlin/theodolite/k8s/K8sResourceLoader.kt b/theodolite/src/main/kotlin/theodolite/k8s/K8sResourceLoader.kt index faae5ade28deb579df6a463007cbdfbc9cc7706e..3fa727bc92720059e9a65dcbd1fa90a3b88cfd58 100644 --- a/theodolite/src/main/kotlin/theodolite/k8s/K8sResourceLoader.kt +++ b/theodolite/src/main/kotlin/theodolite/k8s/K8sResourceLoader.kt @@ -7,6 +7,7 @@ import io.fabric8.kubernetes.api.model.apps.Deployment import io.fabric8.kubernetes.client.NamespacedKubernetesClient import io.fabric8.kubernetes.client.dsl.base.CustomResourceDefinitionContext import mu.KotlinLogging +import theodolite.util.DeploymentFailedException import theodolite.util.YamlParser private val logger = KotlinLogging.logger {} @@ -120,10 +121,8 @@ class K8sResourceLoader(private val client: NamespacedKubernetesClient) { try { resource = f(path) } catch (e: Exception) { - logger.warn { "You potentially misspelled the path: $path" } - logger.warn { e } + throw IllegalArgumentException("The Resource at path: $path could not be loaded", e) } - if (resource == null) { throw IllegalArgumentException("The Resource at path: $path could not be loaded") } @@ -147,10 +146,7 @@ class K8sResourceLoader(private val client: NamespacedKubernetesClient) { "StatefulSet" -> loadStatefulSet(path) "Execution" -> loadExecution(path) "Benchmark" -> loadBenchmark(path) - else -> { - logger.error { "Error during loading of unspecified resource Kind" } - throw IllegalArgumentException("error while loading resource with kind: $kind") - } + else -> throw IllegalArgumentException("error while loading resource with kind: $kind") } } } diff --git a/theodolite/src/main/kotlin/theodolite/k8s/TopicManager.kt b/theodolite/src/main/kotlin/theodolite/k8s/TopicManager.kt index 8e83883fc881db0f7e2b1b75b2fb7c7322a11a00..f2afd71f6e4b4cf8e7106a8fc8a9bd113d9f36e6 100644 --- a/theodolite/src/main/kotlin/theodolite/k8s/TopicManager.kt +++ b/theodolite/src/main/kotlin/theodolite/k8s/TopicManager.kt @@ -30,8 +30,7 @@ class TopicManager(private val kafkaConfig: Map<String, Any>) { result = kafkaAdmin.createTopics(newTopics) result.all().get() // wait for the future to be completed } catch (e: Exception) { // TopicExistsException - logger.warn(e) { "Error during topic creation." } - logger.debug { e } // TODO remove due to attached exception to warn log? + logger.warn { "Error during topic creation. Error is: ${e.message}" } logger.info { "Remove existing topics." } delete(newTopics.map { topic -> topic.name() }, kafkaAdmin) logger.info { "Will retry the topic creation in ${RETRY_TIME / 1000} seconds." } @@ -94,7 +93,7 @@ class TopicManager(private val kafkaConfig: Map<String, Any>) { }" } } catch (e: Exception) { - logger.error(e) { "Error while removing topics: $e" } + logger.error { "Error while removing topics: ${e.message}" } logger.info { "Existing topics are: ${kafkaAdmin.listTopics().names().get()}." } } diff --git a/theodolite/src/main/kotlin/theodolite/util/Configuration.kt b/theodolite/src/main/kotlin/theodolite/util/Configuration.kt new file mode 100644 index 0000000000000000000000000000000000000000..dac3b943e69bd7e208d318f2a788275f19db11e4 --- /dev/null +++ b/theodolite/src/main/kotlin/theodolite/util/Configuration.kt @@ -0,0 +1,18 @@ +package theodolite.util + +import theodolite.execution.ExecutionModes + +// Defaults +private const val DEFAULT_NAMESPACE = "default" +private const val DEFAULT_COMPONENT_NAME = "theodolite-operator" + + +class Configuration( +) { + companion object { + val NAMESPACE = System.getenv("NAMESPACE") ?: DEFAULT_NAMESPACE + val COMPONENT_NAME = System.getenv("COMPONENT_NAME") ?: DEFAULT_COMPONENT_NAME + val EXECUTION_MODE = System.getenv("MODE") ?: ExecutionModes.STANDALONE.value + } + +} diff --git a/theodolite/src/main/kotlin/theodolite/util/DeploymentFailedException.kt b/theodolite/src/main/kotlin/theodolite/util/DeploymentFailedException.kt index 639a7c86c641cbdcba361410cf5e25fa56dd795f..6fbb5e768c4ef65a7b50345818aecd9050afd0b7 100644 --- a/theodolite/src/main/kotlin/theodolite/util/DeploymentFailedException.kt +++ b/theodolite/src/main/kotlin/theodolite/util/DeploymentFailedException.kt @@ -1,4 +1,4 @@ package theodolite.util -class DeploymentFailedException(message: String) : Exception(message) \ No newline at end of file +open class DeploymentFailedException(message: String, e: Exception? = null) : TheodoliteException(message,e) \ No newline at end of file diff --git a/theodolite/src/main/kotlin/theodolite/util/EvaluationFailedException.kt b/theodolite/src/main/kotlin/theodolite/util/EvaluationFailedException.kt new file mode 100644 index 0000000000000000000000000000000000000000..c67ed7ffd79afc733a97dae05c3203f8e78722ea --- /dev/null +++ b/theodolite/src/main/kotlin/theodolite/util/EvaluationFailedException.kt @@ -0,0 +1,4 @@ +package theodolite.util + +class EvaluationFailedException(message: String, e: Exception? = null) : ExecutionFailedException(message,e) { +} diff --git a/theodolite/src/main/kotlin/theodolite/util/ExecutionFailedException.kt b/theodolite/src/main/kotlin/theodolite/util/ExecutionFailedException.kt new file mode 100644 index 0000000000000000000000000000000000000000..6566a451a3e273214f59962531b6bd17b33a850d --- /dev/null +++ b/theodolite/src/main/kotlin/theodolite/util/ExecutionFailedException.kt @@ -0,0 +1,4 @@ +package theodolite.util + +open class ExecutionFailedException(message: String, e: Exception? = null) : TheodoliteException(message,e) { +} \ No newline at end of file diff --git a/theodolite/src/main/kotlin/theodolite/util/InvalidPatcherConfigurationException.kt b/theodolite/src/main/kotlin/theodolite/util/InvalidPatcherConfigurationException.kt index 81ea227d0d9871c2420a414d81749a34b97676b8..d02948ad341207051c4653ba9400ac0ffe5b03aa 100644 --- a/theodolite/src/main/kotlin/theodolite/util/InvalidPatcherConfigurationException.kt +++ b/theodolite/src/main/kotlin/theodolite/util/InvalidPatcherConfigurationException.kt @@ -1,4 +1,3 @@ package theodolite.util -class InvalidPatcherConfigurationException(message: String, e: Exception? = null) : Exception(message, e) - +class InvalidPatcherConfigurationException(message: String, e: Exception? = null) : DeploymentFailedException(message,e) diff --git a/theodolite/src/main/kotlin/theodolite/util/TheodoliteException.kt b/theodolite/src/main/kotlin/theodolite/util/TheodoliteException.kt new file mode 100644 index 0000000000000000000000000000000000000000..fc7453bae6aaa4c5c526eee72c006562ea887eb5 --- /dev/null +++ b/theodolite/src/main/kotlin/theodolite/util/TheodoliteException.kt @@ -0,0 +1,3 @@ +package theodolite.util + +open class TheodoliteException (message: String, e: Exception? = null) : Exception(message,e) \ No newline at end of file diff --git a/theodolite/src/test/kotlin/theodolite/TestBenchmarkExecutorImpl.kt b/theodolite/src/test/kotlin/theodolite/TestBenchmarkExecutorImpl.kt index cbd2d5926d61b0bfd4de6fab0c14422ddf88f190..948b60c66043dc78e0dc9800b4211d3f891779a3 100644 --- a/theodolite/src/test/kotlin/theodolite/TestBenchmarkExecutorImpl.kt +++ b/theodolite/src/test/kotlin/theodolite/TestBenchmarkExecutorImpl.kt @@ -26,7 +26,8 @@ class TestBenchmarkExecutorImpl( repetitions = 1, executionId = executionId, loadGenerationDelay = loadGenerationDelay, - afterTeardownDelay = afterTeardownDelay + afterTeardownDelay = afterTeardownDelay, + executionName = "test-execution" ) { override fun runExperiment(load: LoadDimension, res: Resource): Boolean {