Skip to content
Snippets Groups Projects
Commit 55d76f79 authored by Lorenz Boguhn's avatar Lorenz Boguhn Committed by Sören Henning
Browse files

Fix the aggregation-deployment correct + ResourceLimitPatcher

parent 449cc5b5
Branches
Tags
4 merge requests!159Re-implementation of Theodolite with Kotlin/Quarkus,!157Update Graal Image in CI pipeline,!85Introduce new Benchmark class and Patcher,!83WIP: Re-implementation of Theodolite with Kotlin/Quarkus
This commit is part of merge request !85. Comments created here will be created in the context of that merge request.
...@@ -3,31 +3,35 @@ package theodolite.patcher ...@@ -3,31 +3,35 @@ package theodolite.patcher
import io.fabric8.kubernetes.api.model.KubernetesResource import io.fabric8.kubernetes.api.model.KubernetesResource
import io.fabric8.kubernetes.api.model.Quantity import io.fabric8.kubernetes.api.model.Quantity
import io.fabric8.kubernetes.api.model.ResourceRequirements import io.fabric8.kubernetes.api.model.ResourceRequirements
import io.fabric8.kubernetes.api.model.ResourceRequirementsBuilder
import io.fabric8.kubernetes.api.model.apps.Deployment import io.fabric8.kubernetes.api.model.apps.Deployment
import io.fabric8.kubernetes.api.model.apps.StatefulSet
import java.lang.IllegalStateException
class ResourceLimitPatcher(private val k8sResource: KubernetesResource, private val container: String, private val variableName: String): AbstractPatcher(k8sResource, container, variableName) { class ResourceLimitPatcher(
private val k8sResource: KubernetesResource,
private val container: String,
private val variableName: String
) : AbstractPatcher(k8sResource, container, variableName) {
override fun <String> patch(value: String) { override fun <String> patch(value: String) {
if (k8sResource is Deployment) { if (k8sResource is Deployment) {
k8sResource.spec.template.spec.containers.filter { it.name == container }.forEach { k8sResource.spec.template.spec.containers.filter { it.name == container }.forEach {
try { try {
println("before: " + it.resources.limits.toString())
println("$variableName to : $value")
if (it.resources.limits.isNullOrEmpty()) { if (it.resources.limits.isNullOrEmpty()) {
it.resources.limits = mapOf(variableName to Quantity(value as kotlin.String)) it.resources.limits = mapOf(variableName to Quantity(value as kotlin.String))
} else { } else {
val values = it.resources.limits val values = Quantity(value as kotlin.String)
println(values) it.resources.limits[variableName] = values
values[variableName] = Quantity(value as kotlin.String)
it.resources.limits = values
} }
} catch (e: IllegalStateException) { } catch (e: IllegalStateException) {
val resource = ResourceRequirements() val resource = ResourceRequirements()
resource.limits = mapOf(variableName to Quantity(value as kotlin.String)) resource.limits = mapOf(variableName to Quantity(value as kotlin.String))
it.resources = resource it.resources = resource
} }
println("after " + it.resources.limits.toString())
} }
} }
} }
......
...@@ -15,7 +15,7 @@ spec: ...@@ -15,7 +15,7 @@ spec:
terminationGracePeriodSeconds: 0 terminationGracePeriodSeconds: 0
containers: containers:
- name: uc-application - name: uc-application
image: uc-app:latest image: ghcr.io/cau-se/theodolite-uc1-kstreams-app:latest
ports: ports:
- containerPort: 5555 - containerPort: 5555
name: jmx name: jmx
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment