From 58f93b1441c66dd8a82635a42a1ce07070b8f4b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Henning?= <soeren.henning@email.uni-kiel.de> Date: Tue, 20 Apr 2021 17:48:42 +0200 Subject: [PATCH] Add brief pause after K8s deletion (fix #220) --- .../benchmark/KubernetesBenchmarkDeployment.kt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KubernetesBenchmarkDeployment.kt b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KubernetesBenchmarkDeployment.kt index 08fdd840d..28a7b12e8 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KubernetesBenchmarkDeployment.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/benchmark/KubernetesBenchmarkDeployment.kt @@ -3,11 +3,14 @@ package theodolite.benchmark import io.fabric8.kubernetes.api.model.KubernetesResource import io.fabric8.kubernetes.client.NamespacedKubernetesClient import io.quarkus.runtime.annotations.RegisterForReflection +import mu.KotlinLogging import org.apache.kafka.clients.admin.NewTopic import theodolite.k8s.K8sManager import theodolite.k8s.TopicManager import theodolite.util.KafkaConfig +private val logger = KotlinLogging.logger {} + /** * Organizes the deployment of benchmarks in Kubernetes. * @@ -26,7 +29,8 @@ class KubernetesBenchmarkDeployment( ) : BenchmarkDeployment { private val kafkaController = TopicManager(this.kafkaConfig) private val kubernetesManager = K8sManager(client) - private val LABEL = "app.kubernetes.io/name=kafka-lag-exporter" + private val LAG_EXPORTER_POD_LABEL = "app.kubernetes.io/name=kafka-lag-exporter" + private val SLEEP_AFTER_K8S_DELETION_MS = 2000L /** * Setup a [KubernetesBenchmark] using the [TopicManager] and the [K8sManager]: @@ -52,7 +56,9 @@ class KubernetesBenchmarkDeployment( resources.forEach { kubernetesManager.remove(it) } + logger.info { "Kubernetes resources deleted. Allow for short pause before continuing." } + Thread.sleep(SLEEP_AFTER_K8S_DELETION_MS) kafkaController.removeTopics(this.topics.map { topic -> topic.name }) - KafkaLagExporterRemover(client).remove(LABEL) + KafkaLagExporterRemover(client).remove(LAG_EXPORTER_POD_LABEL) } } -- GitLab