Skip to content
Snippets Groups Projects
Commit c6739061 authored by Lorenz Boguhn's avatar Lorenz Boguhn
Browse files

Fix logging error

parent 0ccce97d
No related branches found
No related tags found
4 merge requests!159Re-implementation of Theodolite with Kotlin/Quarkus,!157Update Graal Image in CI pipeline,!106Introduce a Theodolite operator,!83WIP: Re-implementation of Theodolite with Kotlin/Quarkus
...@@ -8,8 +8,9 @@ import mu.KotlinLogging ...@@ -8,8 +8,9 @@ import mu.KotlinLogging
import theodolite.benchmark.BenchmarkExecution import theodolite.benchmark.BenchmarkExecution
import theodolite.benchmark.KubernetesBenchmark import theodolite.benchmark.KubernetesBenchmark
import java.lang.Thread.sleep import java.lang.Thread.sleep
import java.util.Queue import java.util.*
import java.util.LinkedList import kotlin.collections.HashMap
import kotlin.collections.set
private val logger = KotlinLogging.logger {} private val logger = KotlinLogging.logger {}
...@@ -30,8 +31,8 @@ class TheodoliteController( ...@@ -30,8 +31,8 @@ class TheodoliteController(
fun create() { fun create() {
informerBenchmarkExecution.addEventHandler(object : ResourceEventHandler<BenchmarkExecution> { informerBenchmarkExecution.addEventHandler(object : ResourceEventHandler<BenchmarkExecution> {
override fun onAdd(execution: BenchmarkExecution) { override fun onAdd(execution: BenchmarkExecution) {
logger.info { "Add new execution ${execution.metadata.name} to queue" }
execution.name = execution.metadata.name execution.name = execution.metadata.name
logger.info { "Add new execution ${execution.metadata.name} to queue" }
executionsQueue.add(execution) executionsQueue.add(execution)
} }
...@@ -51,7 +52,7 @@ class TheodoliteController( ...@@ -51,7 +52,7 @@ class TheodoliteController(
override fun onDelete(execution: BenchmarkExecution, b: Boolean) { override fun onDelete(execution: BenchmarkExecution, b: Boolean) {
logger.info { "Delete execution ${execution.metadata.name} from queue" } logger.info { "Delete execution ${execution.metadata.name} from queue" }
executionsQueue.removeIf{e -> e.name == execution.metadata.name} executionsQueue.removeIf { e -> e.name == execution.metadata.name }
if (::executor.isInitialized && executor.getExecution().name == execution.metadata.name) { if (::executor.isInitialized && executor.getExecution().name == execution.metadata.name) {
executor.stop() executor.stop()
logger.info { "Current benchmark stopped" } logger.info { "Current benchmark stopped" }
...@@ -61,8 +62,8 @@ class TheodoliteController( ...@@ -61,8 +62,8 @@ class TheodoliteController(
informerBenchmarkType.addEventHandler(object : ResourceEventHandler<KubernetesBenchmark> { informerBenchmarkType.addEventHandler(object : ResourceEventHandler<KubernetesBenchmark> {
override fun onAdd(benchmark: KubernetesBenchmark) { override fun onAdd(benchmark: KubernetesBenchmark) {
logger.info { "Add new benchmark ${benchmark.name}" }
benchmark.name = benchmark.metadata.name benchmark.name = benchmark.metadata.name
logger.info { "Add new benchmark ${benchmark.name}" }
benchmarks[benchmark.name] = benchmark benchmarks[benchmark.name] = benchmark
} }
...@@ -81,7 +82,7 @@ class TheodoliteController( ...@@ -81,7 +82,7 @@ class TheodoliteController(
override fun onDelete(benchmark: KubernetesBenchmark, b: Boolean) { override fun onDelete(benchmark: KubernetesBenchmark, b: Boolean) {
logger.info { "Delete benchmark ${benchmark.metadata.name}" } logger.info { "Delete benchmark ${benchmark.metadata.name}" }
benchmarks.remove(benchmark.metadata.name) benchmarks.remove(benchmark.metadata.name)
if(::executor.isInitialized && executor.getBenchmark().name == benchmark.metadata.name) { if (::executor.isInitialized && executor.getBenchmark().name == benchmark.metadata.name) {
executor.stop() executor.stop()
logger.info { "Current benchmark stopped" } logger.info { "Current benchmark stopped" }
} }
...@@ -100,15 +101,18 @@ class TheodoliteController( ...@@ -100,15 +101,18 @@ class TheodoliteController(
} }
} }
} }
@Synchronized @Synchronized
private fun reconcile() { private fun reconcile() {
while(executionsQueue.isNotEmpty() while (executionsQueue.isNotEmpty()
&& ((this::executor.isInitialized && !executor.isRunning) || !this::executor.isInitialized)) { && ((this::executor.isInitialized && !executor.isRunning) || !this::executor.isInitialized)
) {
val execution = executionsQueue.peek() val execution = executionsQueue.peek()
val benchmark = benchmarks[execution.benchmark] val benchmark = benchmarks[execution.benchmark]
if (benchmark == null) { if (benchmark == null) {
logger.debug { "No benchmark found for execution ${execution.benchmark}" } logger.debug { "No benchmark found for execution ${execution.benchmark}" }
sleep(1000)
} else { } else {
logger.info { "Start execution ${execution.name} with benchmark ${benchmark.name}" } logger.info { "Start execution ${execution.name} with benchmark ${benchmark.name}" }
executor = TheodoliteExecutor(config = execution, kubernetesBenchmark = benchmark) executor = TheodoliteExecutor(config = execution, kubernetesBenchmark = benchmark)
...@@ -121,7 +125,7 @@ class TheodoliteController( ...@@ -121,7 +125,7 @@ class TheodoliteController(
sleep(1000) sleep(1000)
} }
} catch (e: Exception) { } catch (e: Exception) {
logger.error { "Error while delete current execution" } logger.error { "Error while delete current execution: $e" }
} }
logger.info { "Execution is finally stopped for execution ${execution.name}" } logger.info { "Execution is finally stopped for execution ${execution.name}" }
} }
......
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