Skip to content
Snippets Groups Projects

Make the clean up of ServiceMonitors optional when Operator is starting

+ 12
5
@@ -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
Loading