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

Fix bug when stopping executions

parent 4dd86699
No related branches found
No related tags found
1 merge request!171Introduce ResourceSets to make loading of resource files more flexible
...@@ -4,10 +4,13 @@ import io.fabric8.kubernetes.api.model.HasMetadata ...@@ -4,10 +4,13 @@ import io.fabric8.kubernetes.api.model.HasMetadata
import io.fabric8.kubernetes.api.model.KubernetesResourceList import io.fabric8.kubernetes.api.model.KubernetesResourceList
import io.fabric8.kubernetes.api.model.Namespaced import io.fabric8.kubernetes.api.model.Namespaced
import io.fabric8.kubernetes.client.CustomResource import io.fabric8.kubernetes.client.CustomResource
import io.fabric8.kubernetes.client.KubernetesClientException
import io.fabric8.kubernetes.client.NamespacedKubernetesClient import io.fabric8.kubernetes.client.NamespacedKubernetesClient
import io.fabric8.kubernetes.client.dsl.MixedOperation import io.fabric8.kubernetes.client.dsl.MixedOperation
import io.fabric8.kubernetes.client.dsl.Resource import io.fabric8.kubernetes.client.dsl.Resource
import mu.KotlinLogging
import java.lang.Thread.sleep import java.lang.Thread.sleep
private val logger = KotlinLogging.logger {}
abstract class AbstractStateHandler<T, L, D>( abstract class AbstractStateHandler<T, L, D>(
private val client: NamespacedKubernetesClient, private val client: NamespacedKubernetesClient,
...@@ -20,11 +23,15 @@ abstract class AbstractStateHandler<T, L, D>( ...@@ -20,11 +23,15 @@ abstract class AbstractStateHandler<T, L, D>(
@Synchronized @Synchronized
override fun setState(resourceName: String, f: (T) -> T?) { override fun setState(resourceName: String, f: (T) -> T?) {
this.crdClient try {
.list().items this.crdClient
.filter { it.metadata.name == resourceName } .list().items
.map { customResource -> f(customResource) } .filter { it.metadata.name == resourceName }
.forEach { this.crdClient.updateStatus(it) } .map { customResource -> f(customResource) }
.forEach { this.crdClient.updateStatus(it) }
} catch (e: KubernetesClientException) {
logger.warn { "Status cannot be set for resource $resourceName" }
}
} }
@Synchronized @Synchronized
......
...@@ -80,7 +80,7 @@ class ExecutionHandler( ...@@ -80,7 +80,7 @@ class ExecutionHandler(
override fun onDelete(execution: ExecutionCRD, b: Boolean) { override fun onDelete(execution: ExecutionCRD, b: Boolean) {
logger.info { "Delete execution ${execution.metadata.name}" } logger.info { "Delete execution ${execution.metadata.name}" }
if (execution.status.executionState == States.RUNNING.value if (execution.status.executionState == States.RUNNING.value
&& this.controller.isExecutionRunning(execution.spec.name) && this.controller.isExecutionRunning(execution.metadata.name)
) { ) {
this.controller.stop() this.controller.stop()
} }
......
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