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

make service monitor clean up optional when operator is starting

parent 9c9fe55d
No related branches found
No related tags found
1 merge request!262Make the clean up of ServiceMonitors optional when Operator is starting
Pipeline #7302 passed
......@@ -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
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