Skip to content
Snippets Groups Projects
Commit c3821898 authored by Sören Henning's avatar Sören Henning
Browse files

Merge branch '248-fix' into 'master'

Fix "Deployment not deleted with Flink"

Closes #248

See merge request !177
parents c04b712f b5420942
No related branches found
No related tags found
1 merge request!177Fix "Deployment not deleted with Flink"
Pipeline #4444 passed
......@@ -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." }
}
......
......@@ -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)
}
}
......
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