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

Merge branch 'master' of git.se.informatik.uni-kiel.de:she/theodolite

parents aefbabaf 854acf9a
Branches
Tags
No related merge requests found
...@@ -38,7 +38,7 @@ class ActionSelector { ...@@ -38,7 +38,7 @@ class ActionSelector {
@JsonDeserialize @JsonDeserialize
@RegisterForReflection @RegisterForReflection
class PodSelector { class PodSelector {
lateinit var matchLabels: MutableMap<String, String> lateinit var matchLabels: Map<String, String>
} }
@JsonDeserialize @JsonDeserialize
@RegisterForReflection @RegisterForReflection
......
...@@ -33,7 +33,7 @@ class ActionCommand(val client: NamespacedKubernetesClient) { ...@@ -33,7 +33,7 @@ class ActionCommand(val client: NamespacedKubernetesClient) {
* @return the exit code of this executed command * @return the exit code of this executed command
*/ */
fun exec( fun exec(
matchLabels: MutableMap<String, String>, matchLabels: Map<String, String>,
command: Array<String>, command: Array<String>,
timeout: Long = Configuration.TIMEOUT_SECONDS, timeout: Long = Configuration.TIMEOUT_SECONDS,
container: String = "" container: String = ""
...@@ -58,7 +58,7 @@ class ActionCommand(val client: NamespacedKubernetesClient) { ...@@ -58,7 +58,7 @@ class ActionCommand(val client: NamespacedKubernetesClient) {
val latchTerminationStatus = execLatch.await(timeout, TimeUnit.SECONDS) val latchTerminationStatus = execLatch.await(timeout, TimeUnit.SECONDS)
if (!latchTerminationStatus) { if (!latchTerminationStatus) {
throw ActionCommandFailedException("Latch could not terminate within specified time") throw ActionCommandFailedException("Timeout while running action command")
} }
execWatch.close() execWatch.close()
} catch (e: Exception) { } catch (e: Exception) {
...@@ -112,7 +112,7 @@ class ActionCommand(val client: NamespacedKubernetesClient) { ...@@ -112,7 +112,7 @@ class ActionCommand(val client: NamespacedKubernetesClient) {
* it can take a while until the status is ready and the pod can be selected. * it can take a while until the status is ready and the pod can be selected.
* @return the name of the pod or throws [ActionCommandFailedException] * @return the name of the pod or throws [ActionCommandFailedException]
*/ */
fun getPodName(matchLabels: MutableMap<String, String>, tries: Int): String { fun getPodName(matchLabels: Map<String, String>, tries: Int): String {
for (i in 1..tries) { for (i in 1..tries) {
try { try {
...@@ -125,7 +125,7 @@ class ActionCommand(val client: NamespacedKubernetesClient) { ...@@ -125,7 +125,7 @@ class ActionCommand(val client: NamespacedKubernetesClient) {
throw ActionCommandFailedException("Couldn't find any pod that matches the specified labels.") throw ActionCommandFailedException("Couldn't find any pod that matches the specified labels.")
} }
private fun getPodName(matchLabels: MutableMap<String, String>): String { private fun getPodName(matchLabels: Map<String, String>): String {
return try { return try {
val podNames = this.client val podNames = this.client
.pods() .pods()
......
...@@ -54,7 +54,7 @@ class MetricFetcher(private val prometheusURL: String, private val offset: Durat ...@@ -54,7 +54,7 @@ class MetricFetcher(private val prometheusURL: String, private val offset: Durat
} else { } else {
val values = parseValues(response) val values = parseValues(response)
if (values.data?.result.isNullOrEmpty()) { if (values.data?.result.isNullOrEmpty()) {
throw NoSuchFieldException("Empty query result: $values between $start and $end for query $query.") throw NoSuchFieldException("Empty query result: $values between for query '$query' in interval [$offsetStart,$offsetEnd] .")
} }
return parseValues(response) return parseValues(response)
} }
......
...@@ -190,7 +190,7 @@ class BenchmarkStateChecker( ...@@ -190,7 +190,7 @@ class BenchmarkStateChecker(
} }
} }
private fun <K, V> MutableMap<K, V>.containsMatchLabels(matchLabels: MutableMap<V, V>): Boolean { private fun <K, V> Map<K, V>.containsMatchLabels(matchLabels: Map<V, V>): Boolean {
for (kv in matchLabels) { for (kv in matchLabels) {
if (kv.value != this[kv.key as K]) { if (kv.value != this[kv.key as K]) {
return false return false
......
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
...@@ -102,7 +102,7 @@ class ActionCommandTest { ...@@ -102,7 +102,7 @@ class ActionCommandTest {
val action = Action() val action = Action()
action.selector = ActionSelector() action.selector = ActionSelector()
action.selector.pod = PodSelector() action.selector.pod = PodSelector()
action.selector.pod.matchLabels = mutableMapOf("app" to "pod") action.selector.pod.matchLabels = mapOf("app" to "pod")
action.exec = Command() action.exec = Command()
action.exec.command = arrayOf("ls") action.exec.command = arrayOf("ls")
action.exec.timeoutSeconds = 10L action.exec.timeoutSeconds = 10L
...@@ -118,7 +118,7 @@ class ActionCommandTest { ...@@ -118,7 +118,7 @@ class ActionCommandTest {
val action = Action() val action = Action()
action.selector = ActionSelector() action.selector = ActionSelector()
action.selector.pod = PodSelector() action.selector.pod = PodSelector()
action.selector.pod.matchLabels = mutableMapOf("app" to "pod") action.selector.pod.matchLabels = mapOf("app" to "pod")
action.exec = Command() action.exec = Command()
action.exec.command = arrayOf("error-command") action.exec.command = arrayOf("error-command")
action.exec.timeoutSeconds = 10L action.exec.timeoutSeconds = 10L
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment