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

fix: wait only for pods which have exactly the same much labels and not only the same app lable

parent c04b712f
No related branches found
No related tags found
1 merge request!177Fix "Deployment not deleted with Flink"
...@@ -46,8 +46,7 @@ class K8sManager(private val client: NamespacedKubernetesClient) { ...@@ -46,8 +46,7 @@ class K8sManager(private val client: NamespacedKubernetesClient) {
this.client.apps().deployments().delete(resource) this.client.apps().deployments().delete(resource)
ResourceByLabelHandler(client = client) ResourceByLabelHandler(client = client)
.blockUntilPodsDeleted( .blockUntilPodsDeleted(
labelName = "app", matchLabels = resource.spec.selector.matchLabels
labelValue = resource.spec.selector.matchLabels["app"]!!
) )
logger.info { "Deployment '${resource.metadata.name}' deleted." } logger.info { "Deployment '${resource.metadata.name}' deleted." }
} }
...@@ -59,8 +58,7 @@ class K8sManager(private val client: NamespacedKubernetesClient) { ...@@ -59,8 +58,7 @@ class K8sManager(private val client: NamespacedKubernetesClient) {
this.client.apps().statefulSets().delete(resource) this.client.apps().statefulSets().delete(resource)
ResourceByLabelHandler(client = client) ResourceByLabelHandler(client = client)
.blockUntilPodsDeleted( .blockUntilPodsDeleted(
labelName = "app", matchLabels = resource.spec.selector.matchLabels
labelValue = resource.spec.selector.matchLabels["app"]!!
) )
logger.info { "StatefulSet '$resource.metadata.name' deleted." } logger.info { "StatefulSet '$resource.metadata.name' deleted." }
} }
......
...@@ -99,16 +99,16 @@ class ResourceByLabelHandler(private val client: NamespacedKubernetesClient) { ...@@ -99,16 +99,16 @@ class ResourceByLabelHandler(private val client: NamespacedKubernetesClient) {
* @param [labelName] the label name * @param [labelName] the label name
* @param [labelValue] the value of this label * @param [labelValue] the value of this label
* */ * */
fun blockUntilPodsDeleted(labelName: String, labelValue: String) { fun blockUntilPodsDeleted(matchLabels: MutableMap<String, String>) {
while ( while (
!this.client !this.client
.pods() .pods()
.withLabel("$labelName=$labelValue") .withLabels(matchLabels)
.list() .list()
.items .items
.isNullOrEmpty() .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) Thread.sleep(1000)
} }
} }
......
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