From a4577aaa6e436812c55c4d8bdb0c8858bd0a7197 Mon Sep 17 00:00:00 2001
From: lorenz <stu203404@mail.uni-kiel.de>
Date: Sat, 27 Mar 2021 19:19:01 +0100
Subject: [PATCH] Cleanup + fix dockerfile + enhance default configs

---
 .../src/main/docker/Dockerfile.jvm             |  2 +-
 .../benchmark/KubernetesBenchmark.kt           |  6 +++++-
 .../theodolite/execution/TheodoliteOperator.kt | 18 ++++++++++++------
 .../src/main/resources/application.properties  |  2 +-
 .../resources/operator/example-benchmark.yaml  |  2 +-
 5 files changed, 20 insertions(+), 10 deletions(-)

diff --git a/theodolite-quarkus/src/main/docker/Dockerfile.jvm b/theodolite-quarkus/src/main/docker/Dockerfile.jvm
index 6733d5d44..232ab0397 100644
--- a/theodolite-quarkus/src/main/docker/Dockerfile.jvm
+++ b/theodolite-quarkus/src/main/docker/Dockerfile.jvm
@@ -41,7 +41,7 @@ RUN microdnf install curl ca-certificates ${JAVA_PACKAGE} \
     && echo "securerandom.source=file:/dev/urandom" >> /etc/alternatives/jre/lib/security/java.security
 
 # Configure the JAVA_OPTIONS, you can add -XshowSettings:vm to also display the heap size.
-ENV JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager"
+ENV JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager -Dquarkus.package.main-class=TheodoliteOperator"
 COPY build/lib/* /deployments/lib/
 COPY build/*-runner.jar /deployments/app.jar
 COPY config/ /deployments/config/
diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KubernetesBenchmark.kt b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KubernetesBenchmark.kt
index d0640cd7b..4f630ff6b 100644
--- a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KubernetesBenchmark.kt
+++ b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KubernetesBenchmark.kt
@@ -30,6 +30,10 @@ class KubernetesBenchmark : Benchmark, CustomResource(), Namespaced {
         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." }
+
+
         val loader = K8sResourceLoader(DefaultKubernetesClient().inNamespace(namespace))
         return resources
             .map { resource ->
@@ -62,7 +66,7 @@ class KubernetesBenchmark : Benchmark, CustomResource(), Namespaced {
                 patcherFactory.createPatcher(it.patcher, resources).patch(override.value)
             }
         }
-        
+
         return KubernetesBenchmarkDeployment(
             namespace = namespace,
             resources = resources.map { r -> r.second },
diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/execution/TheodoliteOperator.kt b/theodolite-quarkus/src/main/kotlin/theodolite/execution/TheodoliteOperator.kt
index 5b621c3c4..478fdce0c 100644
--- a/theodolite-quarkus/src/main/kotlin/theodolite/execution/TheodoliteOperator.kt
+++ b/theodolite-quarkus/src/main/kotlin/theodolite/execution/TheodoliteOperator.kt
@@ -2,10 +2,13 @@ package theodolite.execution
 
 import io.fabric8.kubernetes.client.DefaultKubernetesClient
 import io.fabric8.kubernetes.client.dsl.base.CustomResourceDefinitionContext
+import io.fabric8.kubernetes.internal.KubernetesDeserializer
 import io.quarkus.runtime.annotations.QuarkusMain
 import mu.KotlinLogging
-import theodolite.benchmark.*
-import io.fabric8.kubernetes.internal.KubernetesDeserializer
+import theodolite.benchmark.BenchmarkExecution
+import theodolite.benchmark.BenchmarkExecutionList
+import theodolite.benchmark.KubernetesBenchmark
+import theodolite.benchmark.KubernetesBenchmarkList
 
 
 private var DEFAULT_NAMESPACE = "default"
@@ -19,6 +22,7 @@ object TheodoliteOperator {
         val namespace = System.getenv("NAMESPACE") ?: DEFAULT_NAMESPACE
         logger.info { "Using $namespace as namespace." }
 
+
         val client = DefaultKubernetesClient().inNamespace(namespace)
 
         KubernetesDeserializer.registerCustomKind(
@@ -49,19 +53,21 @@ object TheodoliteOperator {
 
         val informerFactory = client.informers()
 
-        val  informerBenchmarkExecution = informerFactory.sharedIndexInformerForCustomResource(
+        val informerBenchmarkExecution = informerFactory.sharedIndexInformerForCustomResource(
             executionContext, BenchmarkExecution::class.java,
             BenchmarkExecutionList::class.java, 10 * 60 * 1000.toLong()
         )
 
-       val informerBenchmarkType = informerFactory.sharedIndexInformerForCustomResource(
+        val informerBenchmarkType = informerFactory.sharedIndexInformerForCustomResource(
             typeContext, KubernetesBenchmark::class.java,
             KubernetesBenchmarkList::class.java, 10 * 60 * 1000.toLong()
         )
-        val controller = TheodoliteController(client = client,
+        val controller = TheodoliteController(
+            client = client,
             informerBenchmarkExecution = informerBenchmarkExecution,
             informerBenchmarkType = informerBenchmarkType,
-            executionContext = executionContext)
+            executionContext = executionContext
+        )
 
         controller.create()
         informerFactory.startAllRegisteredInformers()
diff --git a/theodolite-quarkus/src/main/resources/application.properties b/theodolite-quarkus/src/main/resources/application.properties
index 318ce68ff..e85374958 100644
--- a/theodolite-quarkus/src/main/resources/application.properties
+++ b/theodolite-quarkus/src/main/resources/application.properties
@@ -1,4 +1,4 @@
-quarkus.package.main-class=TheodoliteYamlExecutor
+quarkus.package.main-class=TheodoliteOperator
 quarkus.native.additional-build-args=\
   --initialize-at-run-time=io.fabric8.kubernetes.client.internal.CertUtils,\
   --report-unsupported-elements-at-runtime
\ No newline at end of file
diff --git a/theodolite-quarkus/src/main/resources/operator/example-benchmark.yaml b/theodolite-quarkus/src/main/resources/operator/example-benchmark.yaml
index 9fc16f92e..d5fc040b3 100644
--- a/theodolite-quarkus/src/main/resources/operator/example-benchmark.yaml
+++ b/theodolite-quarkus/src/main/resources/operator/example-benchmark.yaml
@@ -22,7 +22,7 @@ loadTypes:
         container: "workload-generator"
         variableName: "NUM_SENSORS"
 kafkaConfig:
-  bootstrapServer: "localhost:31290"
+  bootstrapServer: "my-confluent-cp-kafka:9092"
   topics:
     - name: "input"
       numPartitions: 40
-- 
GitLab