diff --git a/theodolite/src/main/kotlin/theodolite/execution/operator/ClusterSetup.kt b/theodolite/src/main/kotlin/theodolite/execution/operator/ClusterSetup.kt index 885315df6eda0d91a27567720056738b997a8ec1..bd283a75a48ffb9c48a411386342f2be819ab26b 100644 --- a/theodolite/src/main/kotlin/theodolite/execution/operator/ClusterSetup.kt +++ b/theodolite/src/main/kotlin/theodolite/execution/operator/ClusterSetup.kt @@ -3,11 +3,14 @@ package theodolite.execution.operator import io.fabric8.kubernetes.client.NamespacedKubernetesClient import io.fabric8.kubernetes.client.dsl.MixedOperation import io.fabric8.kubernetes.client.dsl.Resource +import mu.KotlinLogging import theodolite.execution.Shutdown import theodolite.k8s.K8sContextFactory import theodolite.k8s.ResourceByLabelHandler import theodolite.model.crd.* +private val logger = KotlinLogging.logger {} + class ClusterSetup( private val executionCRDClient: MixedOperation<ExecutionCRD, BenchmarkExecutionList, Resource<ExecutionCRD>>, private val benchmarkCRDClient: MixedOperation<BenchmarkCRD, KubernetesBenchmarkList, Resource<BenchmarkCRD>>, @@ -75,10 +78,14 @@ class ClusterSetup( labelName = "app.kubernetes.io/created-by", labelValue = "theodolite" ) - resourceRemover.removeCR( - labelName = "app.kubernetes.io/created-by", - labelValue = "theodolite", - context = serviceMonitorContext - ) + try{ + resourceRemover.removeCR( + labelName = "app.kubernetes.io/created-by", + labelValue = "theodolite", + context = serviceMonitorContext + ) + } catch (e: Exception) { + logger.warn { "Service monitors could not be cleaned up. It may be that service monitors are not registered by the Kubernetes API." } + } } } \ No newline at end of file