Skip to content
Snippets Groups Projects
Commit a55c10a9 authored by Lorenz Boguhn's avatar Lorenz Boguhn Committed by Lorenz Boguhn
Browse files

Cleanup

parent ac95105d
No related branches found
No related tags found
4 merge requests!159Re-implementation of Theodolite with Kotlin/Quarkus,!157Update Graal Image in CI pipeline,!92Introduce experiment evaluation,!83WIP: Re-implementation of Theodolite with Kotlin/Quarkus
...@@ -46,7 +46,6 @@ def execute(results, threshold, warmup): ...@@ -46,7 +46,6 @@ def execute(results, threshold, warmup):
@app.post("/evaluate-slope",response_model=bool) @app.post("/evaluate-slope",response_model=bool)
async def evaluate_slope(request: Request): async def evaluate_slope(request: Request):
data = json.loads(await request.body()) data = json.loads(await request.body())
logger.info("Request received") return execute(data['total_lag'], data['threshold'], data['warmup'])
return execute(data['total_lag'], data['threshold'],data['warmup'])
logger.info("Slope evaluator is online") logger.info("Slope evaluator is online")
\ No newline at end of file
...@@ -25,9 +25,8 @@ dependencies { ...@@ -25,9 +25,8 @@ dependencies {
implementation 'org.slf4j:slf4j-simple:1.7.29' implementation 'org.slf4j:slf4j-simple:1.7.29'
implementation 'io.github.microutils:kotlin-logging:1.12.0' implementation 'io.github.microutils:kotlin-logging:1.12.0'
implementation 'io.fabric8:kubernetes-client:5.0.0-alpha-2' implementation 'io.fabric8:kubernetes-client:5.0.0-alpha-2'
compile group: 'org.apache.kafka', name: 'kafka-clients', version: '2.7.0' implementation 'org.apache.kafka:kafka-clients:2.7.0'
compile group: 'org.apache.zookeeper', name: 'zookeeper', version: '3.6.2' implementation 'khttp:khttp:1.0.0'
compile "khttp:khttp:1.0.0"
} }
group 'theodolite' group 'theodolite'
......
...@@ -16,6 +16,9 @@ class ExternalSloChecker( ...@@ -16,6 +16,9 @@ class ExternalSloChecker(
) : ) :
SloChecker { SloChecker {
private val RETRYS = 2
private val TIMEOUT = 60.0
override fun evaluate(start: Instant, end: Instant): Boolean { override fun evaluate(start: Instant, end: Instant): Boolean {
var counter = 0 var counter = 0
val metricFetcher = MetricFetcher(prometheusURL = prometheusURL, offset = offset) val metricFetcher = MetricFetcher(prometheusURL = prometheusURL, offset = offset)
...@@ -23,8 +26,8 @@ class ExternalSloChecker( ...@@ -23,8 +26,8 @@ class ExternalSloChecker(
val data = val data =
Gson().toJson(mapOf("total_lag" to fetchedData.data?.result, "threshold" to threshold, "warmup" to warmup)) Gson().toJson(mapOf("total_lag" to fetchedData.data?.result, "threshold" to threshold, "warmup" to warmup))
while (counter < 2) { while (counter < RETRYS) {
val result = post(externalSlopeURL, data = data, timeout = 60.0) val result = post(externalSlopeURL, data = data, timeout = TIMEOUT)
if (result.statusCode != 200) { if (result.statusCode != 200) {
counter++ counter++
} else { } else {
......
...@@ -12,13 +12,15 @@ import java.time.Instant ...@@ -12,13 +12,15 @@ import java.time.Instant
private val logger = KotlinLogging.logger {} private val logger = KotlinLogging.logger {}
class MetricFetcher(private val prometheusURL: String, private val offset: Duration) { class MetricFetcher(private val prometheusURL: String, private val offset: Duration) {
private val RETRYS = 2
private val TIMEOUT = 60.0
fun fetchMetric(start: Instant, end: Instant, query: String): PrometheusResponse { fun fetchMetric(start: Instant, end: Instant, query: String): PrometheusResponse {
val offsetStart = start.minus(offset) val offsetStart = start.minus(offset)
val offsetEnd = end.minus(offset) val offsetEnd = end.minus(offset)
var trys = 0 var counter = 0
val parameter = mapOf( val parameter = mapOf(
"query" to query, "query" to query,
"start" to offsetStart.toString(), "start" to offsetStart.toString(),
...@@ -26,12 +28,12 @@ class MetricFetcher(private val prometheusURL: String, private val offset: Durat ...@@ -26,12 +28,12 @@ class MetricFetcher(private val prometheusURL: String, private val offset: Durat
"step" to "5s" "step" to "5s"
) )
while (trys < 2) { while (counter < RETRYS) {
val response = get("$prometheusURL/api/v1/query_range", params = parameter, timeout = 60.0) val response = get("$prometheusURL/api/v1/query_range", params = parameter, timeout = TIMEOUT)
if (response.statusCode != 200) { if (response.statusCode != 200) {
val message = response.jsonObject.toString() val message = response.jsonObject.toString()
logger.warn { "Could not connect to Prometheus: $message, retrying now" } logger.warn { "Could not connect to Prometheus: $message, retrying now" }
trys++ counter++
} else { } else {
val values = parseValues(response) val values = parseValues(response)
if (values.data?.result.isNullOrEmpty()) { if (values.data?.result.isNullOrEmpty()) {
......
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