From e86c5d16c6a1d5dda8272ced28da72a43aa26764 Mon Sep 17 00:00:00 2001 From: "stu126940@mail.uni-kiel.de" <stu126940@mail.uni-kiel.de> Date: Tue, 29 Mar 2022 13:38:00 +0200 Subject: [PATCH] make service monitor clean up optional when operator is starting --- .../execution/operator/ClusterSetup.kt | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/theodolite/src/main/kotlin/theodolite/execution/operator/ClusterSetup.kt b/theodolite/src/main/kotlin/theodolite/execution/operator/ClusterSetup.kt index 885315df6..bd283a75a 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 -- GitLab