diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/patcher/EnvVarPatcher.kt b/theodolite-quarkus/src/main/kotlin/theodolite/patcher/EnvVarPatcher.kt index a383b480dc87366e93426825aa9d066d3e2fff86..941890ca36d339f61b3e9a52d32b7cc0c6f6deeb 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/patcher/EnvVarPatcher.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/patcher/EnvVarPatcher.kt @@ -16,13 +16,13 @@ class EnvVarPatcher(private val k8sResource: KubernetesResource, private val con } /** - * Sets the ContainerEvironmentVariables, creates new if variable does not exist. + * Sets the ContainerEnvironmentVariables, creates new if variable does not exist. * @param container - The Container - * @param map - Map of k=Name,v =Value of EnviromentVariables + * @param map - Map of k=Name,v =Value of EnvironmentVariables */ private fun setContainerEnv(container: Container, map: Map<String, String>) { - map.forEach { k, v -> - // filter for mathing name and set value + map.forEach { (k, v) -> + // filter for matching name and set value val x = container.env.filter { envVar -> envVar.name == k } if (x.isEmpty()) { diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/patcher/ImagePatcher.kt b/theodolite-quarkus/src/main/kotlin/theodolite/patcher/ImagePatcher.kt index 3a7f39ccedd6c13bf5095b66d06c51c81eba9fe3..f1ac252fa7d555454e60875c74c569f2393ca695 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/patcher/ImagePatcher.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/patcher/ImagePatcher.kt @@ -1,20 +1,19 @@ package theodolite.patcher import io.fabric8.kubernetes.api.model.KubernetesResource -import io.fabric8.kubernetes.api.model.Quantity import io.fabric8.kubernetes.api.model.apps.Deployment import io.fabric8.kubernetes.api.model.apps.StatefulSet -class ImagePatcher(private val k8sResource: KubernetesResource, private val container: String, private val variableName: String): AbstractPatcher(k8sResource, container, variableName) { +class ImagePatcher(private val k8sResource: KubernetesResource, private val container: String): AbstractPatcher(k8sResource, container) { - override fun <String> patch(value: String) { + override fun <String> patch(imagePath: String) { if (k8sResource is Deployment) { k8sResource.spec.template.spec.containers.filter { it.name == container }.forEach { - it.image = value as kotlin.String + it.image = imagePath as kotlin.String } } else if (k8sResource is StatefulSet) { k8sResource.spec.template.spec.containers.filter { it.name == container }.forEach { - it.image = value as kotlin.String + it.image = imagePath as kotlin.String } } } diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/patcher/ResourceLimitPatcher.kt b/theodolite-quarkus/src/main/kotlin/theodolite/patcher/ResourceLimitPatcher.kt index 5001371821ace60d14f75c838f3679733158b8cd..d3ca8e656ee4be60e2c0a71a84a60927b24dad29 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/patcher/ResourceLimitPatcher.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/patcher/ResourceLimitPatcher.kt @@ -8,25 +8,24 @@ import io.fabric8.kubernetes.api.model.apps.Deployment class ResourceLimitPatcher( private val k8sResource: KubernetesResource, private val container: String, - private val variableName: String -) : AbstractPatcher(k8sResource, container, variableName) { + private val limitedResource: String +) : AbstractPatcher(k8sResource, container, limitedResource) { override fun <String> patch(value: String) { - if (k8sResource is Deployment) { k8sResource.spec.template.spec.containers.filter { it.name == container }.forEach { try { if (it.resources.limits.isEmpty()) { - it.resources.limits = mapOf(variableName to Quantity(value as kotlin.String)) + it.resources.limits = mapOf(limitedResource to Quantity(value as kotlin.String)) } else { val values = mutableMapOf<kotlin.String, Quantity>() - it.resources.limits.forEach { entry -> values.put(entry.key, entry.value) } - values[variableName] = Quantity(value as kotlin.String) + it.resources.limits.forEach { entry -> values[entry.key] = entry.value } + values[limitedResource] = Quantity(value as kotlin.String) it.resources.limits = values } } catch (e: IllegalStateException) { val resource = ResourceRequirements() - resource.limits = mapOf(variableName to Quantity(value as kotlin.String)) + resource.limits = mapOf(limitedResource to Quantity(value as kotlin.String)) it.resources = resource } } diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/patcher/ResourceRequestPatcher.kt b/theodolite-quarkus/src/main/kotlin/theodolite/patcher/ResourceRequestPatcher.kt index ffb28db4531fefe51b3db87c0363f9fda489769a..d6090875e970c01dd41aa4b448ba704734475cc4 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/patcher/ResourceRequestPatcher.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/patcher/ResourceRequestPatcher.kt @@ -8,24 +8,24 @@ import io.fabric8.kubernetes.api.model.apps.Deployment class ResourceRequestPatcher( private val k8sResource: KubernetesResource, private val container: String, - private val variableName: String -) : AbstractPatcher(k8sResource, container, variableName) { + private val requestedResource: String +) : AbstractPatcher(k8sResource, container, requestedResource) { override fun <String> patch(value: String) { if (k8sResource is Deployment) { k8sResource.spec.template.spec.containers.filter { it.name == container }.forEach { try { if (it.resources.requests.isEmpty()) { - it.resources.requests = mapOf(variableName to Quantity(value as kotlin.String)) + it.resources.requests = mapOf(requestedResource to Quantity(value as kotlin.String)) } else { val values = mutableMapOf<kotlin.String, Quantity>() - it.resources.requests.forEach { entry -> values.put(entry.key, entry.value) } - values[variableName] = Quantity(value as kotlin.String) + it.resources.requests.forEach { entry -> values[entry.key] = entry.value } + values[requestedResource] = Quantity(value as kotlin.String) it.resources.requests = values } } catch (e: IllegalStateException) { val resource = ResourceRequirements() - resource.requests = mapOf(variableName to Quantity(value as kotlin.String)) + resource.requests = mapOf(requestedResource to Quantity(value as kotlin.String)) it.resources = resource } } diff --git a/theodolite-quarkus/src/main/resources/yaml/testBenchmarkType.yaml b/theodolite-quarkus/src/main/resources/yaml/testBenchmarkType.yaml index c0d0346597a7b54b1b62b5a3f8334d9fd14be5d8..de1db3c71b5a59253ed47cbe04ffeca5062d3f01 100644 --- a/theodolite-quarkus/src/main/resources/yaml/testBenchmarkType.yaml +++ b/theodolite-quarkus/src/main/resources/yaml/testBenchmarkType.yaml @@ -18,7 +18,7 @@ loadTypes: container: "workload-generator" variableName: "NUM_SENSORS" kafkaConfig: - bootstrapSever: "localhost:31290" + bootstrapServer: "localhost:31290" topics: - name: "input" partition: "1"