From b5420942d63c411eeaa1b4df793471464356dc28 Mon Sep 17 00:00:00 2001 From: "stu126940@mail.uni-kiel.de" <stu126940@mail.uni-kiel.de> Date: Wed, 8 Sep 2021 18:39:29 +0200 Subject: [PATCH] fix: wait only for pods which have exactly the same much labels and not only the same app lable --- theodolite/src/main/kotlin/theodolite/k8s/K8sManager.kt | 6 ++---- .../main/kotlin/theodolite/k8s/ResourceByLabelHandler.kt | 6 +++--- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/theodolite/src/main/kotlin/theodolite/k8s/K8sManager.kt b/theodolite/src/main/kotlin/theodolite/k8s/K8sManager.kt index abeb1c514..389d5eefa 100644 --- a/theodolite/src/main/kotlin/theodolite/k8s/K8sManager.kt +++ b/theodolite/src/main/kotlin/theodolite/k8s/K8sManager.kt @@ -46,8 +46,7 @@ class K8sManager(private val client: NamespacedKubernetesClient) { this.client.apps().deployments().delete(resource) ResourceByLabelHandler(client = client) .blockUntilPodsDeleted( - labelName = "app", - labelValue = resource.spec.selector.matchLabels["app"]!! + matchLabels = resource.spec.selector.matchLabels ) logger.info { "Deployment '${resource.metadata.name}' deleted." } } @@ -59,8 +58,7 @@ class K8sManager(private val client: NamespacedKubernetesClient) { this.client.apps().statefulSets().delete(resource) ResourceByLabelHandler(client = client) .blockUntilPodsDeleted( - labelName = "app", - labelValue = resource.spec.selector.matchLabels["app"]!! + matchLabels = resource.spec.selector.matchLabels ) logger.info { "StatefulSet '$resource.metadata.name' deleted." } } diff --git a/theodolite/src/main/kotlin/theodolite/k8s/ResourceByLabelHandler.kt b/theodolite/src/main/kotlin/theodolite/k8s/ResourceByLabelHandler.kt index 9f3754c54..28a72c894 100644 --- a/theodolite/src/main/kotlin/theodolite/k8s/ResourceByLabelHandler.kt +++ b/theodolite/src/main/kotlin/theodolite/k8s/ResourceByLabelHandler.kt @@ -99,16 +99,16 @@ class ResourceByLabelHandler(private val client: NamespacedKubernetesClient) { * @param [labelName] the label name * @param [labelValue] the value of this label * */ - fun blockUntilPodsDeleted(labelName: String, labelValue: String) { + fun blockUntilPodsDeleted(matchLabels: MutableMap<String, String>) { while ( !this.client .pods() - .withLabel("$labelName=$labelValue") + .withLabels(matchLabels) .list() .items .isNullOrEmpty() ) { - logger.info { "Wait for pods with label $labelName=$labelValue to be deleted." } + logger.info { "Wait for pods with label ${matchLabels.toString()} to be deleted." } Thread.sleep(1000) } } -- GitLab