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

Merge branch '195-add-benchmark-definitions' of...

Merge branch '195-add-benchmark-definitions' of git.se.informatik.uni-kiel.de:stu126940/spesb into 195-add-benchmark-definitions
parents bd4c87eb 1f7c050e
No related branches found
No related tags found
4 merge requests!159Re-implementation of Theodolite with Kotlin/Quarkus,!157Update Graal Image in CI pipeline,!131Add definitions for UC1, UC2, UC3, UC4,!83WIP: Re-implementation of Theodolite with Kotlin/Quarkus
......@@ -15,7 +15,7 @@ spec:
terminationGracePeriodSeconds: 0
containers:
- name: uc-application
image: ghcr.io/cau-se/theodolite-uc3-kstreams-app:latest
image: ghcr.io/cau-se/theodolite-uc4-kstreams-app:latest
ports:
- containerPort: 5555
name: jmx
......
......@@ -19,6 +19,8 @@ loadTypes:
resource: "uc1-load-generator-deployment.yaml"
container: "workload-generator"
variableName: "NUM_SENSORS"
- type: "NumSensorsLoadGeneratorReplicaPatcher"
resource: "uc1-load-generator-deployment.yaml"
kafkaConfig:
bootstrapServer: "theodolite-cp-kafka:9092"
topics:
......
......@@ -23,6 +23,8 @@ loadTypes:
resource: "uc1-load-generator-deployment.yaml"
container: "workload-generator"
variableName: "NUM_SENSORS"
- type: "NumSensorsLoadGeneratorReplicaPatcher"
resource: "uc1-load-generator-deployment.yaml"
kafkaConfig:
bootstrapServer: "theodolite-cp-kafka:9092"
topics:
......
......@@ -46,10 +46,10 @@ class KubernetesBenchmarkDeployment(
* - Remove the [KubernetesResource]s.
*/
override fun teardown() {
KafkaLagExporterRemover(client).remove(LABEL)
resources.forEach {
kubernetesManager.remove(it)
}
kafkaController.removeTopics(this.topics.map { topic -> topic.name() })
KafkaLagExporterRemover(client).remove(LABEL)
}
}
......@@ -39,16 +39,35 @@ class K8sManager(private val client: NamespacedKubernetesClient) {
*/
fun remove(resource: KubernetesResource) {
when (resource) {
is Deployment ->
is Deployment -> {
val label = resource.spec.selector.matchLabels["app"]!!
this.client.apps().deployments().delete(resource)
blockUntilDeleted(label)
}
is Service ->
this.client.services().delete(resource)
is ConfigMap ->
this.client.configMaps().delete(resource)
is StatefulSet ->
is StatefulSet -> {
val label = resource.spec.selector.matchLabels["app"]!!
this.client.apps().statefulSets().delete(resource)
blockUntilDeleted(label)
}
is ServiceMonitorWrapper -> resource.delete(client)
else -> throw IllegalArgumentException("Unknown Kubernetes resource.")
}
}
private fun blockUntilDeleted(label: String) {
var deleted = false
do {
val pods = this.client.pods().withLabel(label).list().items
if (pods.isNullOrEmpty()) {
deleted = true
}
Thread.sleep(1000)
} while (!deleted)
}
}
......@@ -30,7 +30,9 @@ class TopicManager(private val kafkaConfig: HashMap<String, Any>) {
result.all().get()// wait for the future object
} catch (e: Exception) {
delete(newTopics.map { topic -> topic.name() }, kafkaAdmin)
logger.warn { "Error during topic creation." }
logger.debug { e }
logger.warn { "Will retry the topic creation after 2 seconds" }
sleep(RETRY_TIME)
retryCreation = true
......@@ -52,8 +54,13 @@ class TopicManager(private val kafkaConfig: HashMap<String, Any>) {
*/
fun removeTopics(topics: List<String>) {
val kafkaAdmin: AdminClient = AdminClient.create(this.kafkaConfig)
delete(topics, kafkaAdmin)
kafkaAdmin.close()
}
private fun delete(topics: List<String>, kafkaAdmin: AdminClient) {
var deleted = false
while (!deleted) {
try {
val result = kafkaAdmin.deleteTopics(topics)
......@@ -80,6 +87,6 @@ class TopicManager(private val kafkaConfig: HashMap<String, Any>) {
sleep(RETRY_TIME)
}
}
kafkaAdmin.close()
}
}
......@@ -2,7 +2,6 @@ package theodolite.patcher
import io.fabric8.kubernetes.api.model.Container
import io.fabric8.kubernetes.api.model.EnvVar
import io.fabric8.kubernetes.api.model.EnvVarSource
import io.fabric8.kubernetes.api.model.KubernetesResource
import io.fabric8.kubernetes.api.model.apps.Deployment
......@@ -39,7 +38,9 @@ class EnvVarPatcher(
val x = container.env.filter { envVar -> envVar.name == k }
if (x.isEmpty()) {
val newVar = EnvVar(k, v, EnvVarSource())
val newVar = EnvVar()
newVar.name = k
newVar.value = v
container.env.add(newVar)
} else {
x.forEach {
......
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