Skip to content
Snippets Groups Projects
Commit 854acf9a authored by Sören Henning's avatar Sören Henning
Browse files

Merge branch 'make-sm-cleanup-optional' into 'master'

Make the clean up of ServiceMonitors optional when Operator is starting

See merge request !262
parents 78d4dbfb 0f2eec98
No related branches found
No related tags found
1 merge request!262Make the clean up of ServiceMonitors optional when Operator is starting
Pipeline #7568 passed
package theodolite.execution.operator package theodolite.execution.operator
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 theodolite.execution.Shutdown import theodolite.execution.Shutdown
import theodolite.k8s.K8sContextFactory import theodolite.k8s.K8sContextFactory
import theodolite.k8s.ResourceByLabelHandler import theodolite.k8s.ResourceByLabelHandler
import theodolite.model.crd.* import theodolite.model.crd.*
private val logger = KotlinLogging.logger {}
class ClusterSetup( class ClusterSetup(
private val executionCRDClient: MixedOperation<ExecutionCRD, BenchmarkExecutionList, Resource<ExecutionCRD>>, private val executionCRDClient: MixedOperation<ExecutionCRD, BenchmarkExecutionList, Resource<ExecutionCRD>>,
private val benchmarkCRDClient: MixedOperation<BenchmarkCRD, KubernetesBenchmarkList, Resource<BenchmarkCRD>>, private val benchmarkCRDClient: MixedOperation<BenchmarkCRD, KubernetesBenchmarkList, Resource<BenchmarkCRD>>,
...@@ -75,10 +79,15 @@ class ClusterSetup( ...@@ -75,10 +79,15 @@ class ClusterSetup(
labelName = "app.kubernetes.io/created-by", labelName = "app.kubernetes.io/created-by",
labelValue = "theodolite" labelValue = "theodolite"
) )
try {
resourceRemover.removeCR( resourceRemover.removeCR(
labelName = "app.kubernetes.io/created-by", labelName = "app.kubernetes.io/created-by",
labelValue = "theodolite", labelValue = "theodolite",
context = serviceMonitorContext context = serviceMonitorContext
) )
} catch (e: KubernetesClientException) {
logger.warn { "Service monitors could not be cleaned up. It may be that service monitors are not registered by the Kubernetes API."}
logger.debug { "Error is: ${e.message}" }
}
} }
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment