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

Add execution Id as prefix also for the operator mode

parent 52b1f1fc
No related branches found
No related tags found
4 merge requests!159Re-implementation of Theodolite with Kotlin/Quarkus,!157Update Graal Image in CI pipeline,!111Add prefix to output files to link results and experiment,!83WIP: Re-implementation of Theodolite with Kotlin/Quarkus
......@@ -4,6 +4,7 @@ import io.fabric8.kubernetes.api.model.KubernetesResource
import io.fabric8.kubernetes.api.model.Namespaced
import io.fabric8.kubernetes.client.CustomResource
import io.fabric8.kubernetes.client.DefaultKubernetesClient
import io.fabric8.kubernetes.client.NamespacedKubernetesClient
import io.quarkus.runtime.annotations.RegisterForReflection
import mu.KotlinLogging
import theodolite.k8s.K8sResourceLoader
......@@ -13,6 +14,9 @@ import theodolite.util.*
private val logger = KotlinLogging.logger {}
private var DEFAULT_NAMESPACE = "default"
val namespace: String = System.getenv("NAMESPACE") ?: DEFAULT_NAMESPACE
val client: NamespacedKubernetesClient = DefaultKubernetesClient().inNamespace(namespace)
@RegisterForReflection
class KubernetesBenchmark : Benchmark, CustomResource(), Namespaced {
lateinit var name: String
......@@ -21,16 +25,12 @@ class KubernetesBenchmark : Benchmark, CustomResource(), Namespaced {
lateinit var resourceTypes: List<TypeName>
lateinit var loadTypes: List<TypeName>
lateinit var kafkaConfig: KafkaConfig
lateinit var namespace: String
lateinit var path: String
private fun loadKubernetesResources(resources: List<String>): List<Pair<String, KubernetesResource>> {
val parser = YamlParser()
namespace = System.getenv("NAMESPACE") ?: DEFAULT_NAMESPACE
logger.info { "Using $namespace as namespace." }
path = System.getenv("THEODOLITE_APP_RESOURCES") ?: "./config"
logger.info { "Using $path as path for resources." }
......
......@@ -2,6 +2,7 @@ package theodolite.execution.operator
import io.fabric8.kubernetes.client.NamespacedKubernetesClient
import io.fabric8.kubernetes.client.dsl.base.CustomResourceDefinitionContext
import khttp.patch
import mu.KotlinLogging
import theodolite.benchmark.BenchmarkExecution
import theodolite.benchmark.KubernetesBenchmark
......@@ -10,17 +11,20 @@ import java.lang.Thread.sleep
import java.util.concurrent.ConcurrentHashMap
import java.util.concurrent.ConcurrentLinkedDeque
import java.util.concurrent.atomic.AtomicBoolean
import java.util.concurrent.atomic.AtomicInteger
private val logger = KotlinLogging.logger {}
class TheodoliteController(
val client: NamespacedKubernetesClient,
val executionContext: CustomResourceDefinitionContext
val executionContext: CustomResourceDefinitionContext,
val path: String
) {
lateinit var executor: TheodoliteExecutor
val executionsQueue: ConcurrentLinkedDeque<BenchmarkExecution> = ConcurrentLinkedDeque()
val benchmarks: ConcurrentHashMap<String, KubernetesBenchmark> = ConcurrentHashMap()
var isUpdated = AtomicBoolean(false)
var executionID = AtomicInteger(0)
fun run() {
while (true) {
......@@ -59,7 +63,9 @@ class TheodoliteController(
@Synchronized
fun runExecution(execution: BenchmarkExecution, benchmark: KubernetesBenchmark) {
execution.executionId = executionID.getAndSet(executionID.get() + 1)
isUpdated.set(false)
benchmark.path = path
logger.info { "Start execution ${execution.name} with benchmark ${benchmark.name}." }
executor = TheodoliteExecutor(config = execution, kubernetesBenchmark = benchmark)
executor.run()
......
......@@ -43,7 +43,8 @@ class TheodoliteOperator {
val executionContext = contextFactory.create(API_VERSION, SCOPE, GROUP, EXECUTION_PLURAL)
val benchmarkContext = contextFactory.create(API_VERSION, SCOPE, GROUP, BENCHMARK_PLURAL)
val controller = TheodoliteController(client = client, executionContext = executionContext)
val appResource = System.getenv("THEODOLITE_APP_RESOURCES") ?: "./config"
val controller = TheodoliteController(client = client, executionContext = executionContext, path = appResource)
val informerFactory = client.informers()
val informerExecution = informerFactory.sharedIndexInformerForCustomResource(
......
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