diff --git a/execution/helm/templates/theodolite/crd-benchmark.yaml b/execution/helm/templates/theodolite/crd-benchmark.yaml index 848ecb37213f2810853a47fd45d3869198acd720..319eee18cee87d12cd7051e5fc3414f99c8d8a30 100644 --- a/execution/helm/templates/theodolite/crd-benchmark.yaml +++ b/execution/helm/templates/theodolite/crd-benchmark.yaml @@ -55,12 +55,12 @@ spec: resource: type: string default: "" - container: - type: string - default: "" - variableName: - type: string - default: "" + config: + type: object + additionalProperties: true + x-kubernetes-map-type: "granular" + default: + "": "" loadTypes: type: array minItems: 1 @@ -81,12 +81,12 @@ spec: resource: type: string default: "" - container: - type: string - default: "" - variableName: - type: string - default: "" + config: + type: object + additionalProperties: true + x-kubernetes-map-type: "granular" + default: + "": "" kafkaConfig: type: object properties: diff --git a/execution/helm/templates/theodolite/crd-execution.yaml b/execution/helm/templates/theodolite/crd-execution.yaml index 92835ee1d5a016d0fe6e2db874ae222d7f49f461..41ba1b0b5b19b53d9b7caec48241285edf4ba396 100644 --- a/execution/helm/templates/theodolite/crd-execution.yaml +++ b/execution/helm/templates/theodolite/crd-execution.yaml @@ -1,4 +1,3 @@ -{{- if .Values.executionCRD.create -}} apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: @@ -96,12 +95,12 @@ spec: resource: type: string default: "" - container: - type: string - default: "" - variableName: - type: string - default: "" + config: + type: object + additionalProperties: true + x-kubernetes-map-type: "granular" + default: + "": "" value: type: string status: @@ -127,6 +126,4 @@ spec: jsonPath: .metadata.creationTimestamp subresources: status: {} - scope: Namespaced - status: {} -{{- end }} \ No newline at end of file + scope: Namespaced \ No newline at end of file diff --git a/theodolite-quarkus/config/example-benchmark-yaml-resource.yaml b/theodolite-quarkus/config/example-benchmark-yaml-resource.yaml index c92ffcf78cfc39511d4efd4b57b4fd3a68709b22..ec788031cc0dc58cf8bc7f6d6373e5b4680756b1 100644 --- a/theodolite-quarkus/config/example-benchmark-yaml-resource.yaml +++ b/theodolite-quarkus/config/example-benchmark-yaml-resource.yaml @@ -18,15 +18,12 @@ loadTypes: - type: "EnvVarPatcher" resource: "uc1-load-generator-deployment.yaml" config: - - key: "variableName" - value: "NUM_SENSORS" - - key: "container" - value: "workload-generator" + variableName: "NUM_SENSORS" + container: "workload-generator" - type: "NumSensorsLoadGeneratorReplicaPatcher" - resource: "uc1-load-generator-deploym ent.yaml" + resource: "uc1-load-generator-deployment.yaml" config: - - key: "loadGenMaxRecords" - value: "15000" + loadGenMaxRecords: "15000" kafkaConfig: bootstrapServer: "localhost:31290" topics: diff --git a/theodolite-quarkus/config/example-execution-yaml-resource.yaml b/theodolite-quarkus/config/example-execution-yaml-resource.yaml index 88013ef84b5b03dbd16873b17e1829b120a88d96..0f1e0fc030e66aa05573a441d5c51406854eb3e4 100644 --- a/theodolite-quarkus/config/example-execution-yaml-resource.yaml +++ b/theodolite-quarkus/config/example-execution-yaml-resource.yaml @@ -25,33 +25,27 @@ configOverrides: type: "NodeSelectorPatcher" resource: "uc1-load-generator-deployment.yaml" config: - - key: "variableName" - value: "env" + variableName: "env" value: "prod" - patcher: type: "NodeSelectorPatcher" resource: "uc1-kstreams-deployment.yaml" config: - - key: "variableName" - value: "env" + variableName: "env" value: "prod" - patcher: type: "ResourceLimitPatcher" resource: "uc1-kstreams-deployment.yaml" - config: - - key: "container" - value: "uc-application" - - key: "limitedResource" - value: "cpu" + config: + container: "uc-application" + limitedResource: "cpu" value: "1000m" - patcher: type: "ResourceLimitPatcher" resource: "uc1-kstreams-deployment.yaml" config: - - key: "container" - value: "uc-application" - - key: "limitedResource" - value: "memory" + container: "uc-application" + limitedResource: "memory" value: "2Gi" # - patcher: # type: "SchedulerNamePatcher" diff --git a/theodolite-quarkus/config/example-operator-benchmark.yaml b/theodolite-quarkus/config/example-operator-benchmark.yaml index 5b56c9b5e265e81e778be187d80a3710bc7cbc3c..fcde4a510a4c67a953844f266872071a7d79056a 100644 --- a/theodolite-quarkus/config/example-operator-benchmark.yaml +++ b/theodolite-quarkus/config/example-operator-benchmark.yaml @@ -22,15 +22,12 @@ spec: - type: "EnvVarPatcher" resource: "uc1-load-generator-deployment.yaml" config: - - key: "variableName" - value: "NUM_SENSORS" - - key: "container" - value: "workload-generator" + variableName: "NUM_SENSORS" + container: "workload-generator" - type: "NumSensorsLoadGeneratorReplicaPatcher" resource: "uc1-load-generator-deployment.yaml" config: - - key: "loadGenMaxRecords" - value: "15000" + loadGenMaxRecords: "15000" kafkaConfig: bootstrapServer: "theodolite-cp-kafka:9092" topics: diff --git a/theodolite-quarkus/config/example-operator-execution.yaml b/theodolite-quarkus/config/example-operator-execution.yaml index 10927fb830145554a6bc36e061347fc848e9e7c5..168522430478e48bbf4855f186e9ccb80a22b80f 100644 --- a/theodolite-quarkus/config/example-operator-execution.yaml +++ b/theodolite-quarkus/config/example-operator-execution.yaml @@ -21,41 +21,37 @@ spec: strategy: "LinearSearch" duration: 300 # in seconds repetitions: 1 - delay: 30 # in seconds + loadGenerationDelay: 30 # in seconds restrictions: - "LowerBound" - configOverrides: [] -# - patcher: -# type: "NodeSelectorPatcher" -# resource: "uc1-load-generator-deployment123.yaml" -# variableName: "env" -# value: "prod" -# - patcher: -# type: "NodeSelectorPatcher" -# resource: "uc1-kstreams-deployment.yaml" -# config: -# - key: "variableName" -# value: "env" -# value: "prod" -# - patcher: -# type: "ResourceLimitPatcher" -# resource: "uc1-kstreams-deployment.yaml" -# config: -# - key: "container" -# value: "uc-application" -# - key: "variableName" -# value: "cpu" -# value: "1000m" -# - patcher: -# type: "ResourceLimitPatcher" -# resource: "uc1-kstreams-deployment.yaml" -# config: -# - key: "container" -# value: "uc-application" -# - key: "variableName" -# value: "memory" -# value: "2Gi" -# - patcher: -# type: "SchedulerNamePatcher" -# resource: "uc1-kstreams-deployment.yaml" -# value: "random-scheduler" + configOverrides: + # - patcher: + # type: "NodeSelectorPatcher" + # resource: "uc1-load-generator-deployment.yaml" + # config: + # variableName: "env" + # value: "prod" + # - patcher: + # type: "NodeSelectorPatcher" + # resource: "uc1-kstreams-deployment.yaml" + # config: + # variableName: "env" + # value: "prod" + # - patcher: + # type: "ResourceLimitPatcher" + # resource: "uc1-kstreams-deployment.yaml" + # config: + # container: "uc-application" + # limitedResource: "cpu" + # value: "1000m" + # - patcher: + # type: "ResourceLimitPatcher" + # resource: "uc1-kstreams-deployment.yaml" + # config: + # container: "uc-application" + # limitedResource: "memory" + # value: "2Gi" + # - patcher: + # type: "SchedulerNamePatcher" + # resource: "uc1-kstreams-deployment.yaml" + # value: "random-scheduler" diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/execution/operator/TheodoliteController.kt b/theodolite-quarkus/src/main/kotlin/theodolite/execution/operator/TheodoliteController.kt index 0113ff66969219e34c9413eab74b4bff0cb65a39..9b27dd44d49c91f16317c6742c4189eaf6d2a770 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/execution/operator/TheodoliteController.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/execution/operator/TheodoliteController.kt @@ -183,7 +183,7 @@ class TheodoliteController( val configurationOverride = ConfigurationOverride() configurationOverride.patcher = PatcherDefinition() configurationOverride.patcher.type = "LabelPatcher" - configurationOverride.patcher.config = mutableListOf(hashMapOf("key" to "variableName", "value" to labelName)) + configurationOverride.patcher.config = mapOf("variableName" to labelName) configurationOverride.patcher.resource = it configurationOverride.value = labelValue additionalConfigOverrides.add(configurationOverride) diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/patcher/PatcherFactory.kt b/theodolite-quarkus/src/main/kotlin/theodolite/patcher/PatcherFactory.kt index 29171e53d51d343824e2ac321ee58c496471c09d..be9a0424560daf5762d0f174a45b4f03c5f3f314 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/patcher/PatcherFactory.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/patcher/PatcherFactory.kt @@ -2,6 +2,7 @@ package theodolite.patcher import io.fabric8.kubernetes.api.model.KubernetesResource import theodolite.util.DeploymentFailedException +import theodolite.util.InvalidPatcherConfigurationException import theodolite.util.PatcherDefinition /** @@ -33,46 +34,51 @@ class PatcherFactory { .firstOrNull() ?: throw DeploymentFailedException("Could not find resource ${patcherDefinition.resource}") - - return when (patcherDefinition.type) { - "ReplicaPatcher" -> ReplicaPatcher( - k8sResource = resource - ) - "NumNestedGroupsLoadGeneratorReplicaPatcher" -> NumNestedGroupsLoadGeneratorReplicaPatcher( - k8sResource = resource, - loadGenMaxRecords = patcherDefinition.getValueByKey("loadGenMaxRecords"), - numSensors = patcherDefinition.getValueByKey("numSensors") - ) - "NumSensorsLoadGeneratorReplicaPatcher" -> NumSensorsLoadGeneratorReplicaPatcher( - k8sResource = resource, - loadGenMaxRecords = patcherDefinition.getValueByKey("loadGenMaxRecords") - ) - "EnvVarPatcher" -> EnvVarPatcher( - k8sResource = resource, - container = patcherDefinition.getValueByKey("container"), - variableName = patcherDefinition.getValueByKey("variableName") - ) - "NodeSelectorPatcher" -> NodeSelectorPatcher( - k8sResource = resource, - variableName = patcherDefinition.getValueByKey("variableName")) - "ResourceLimitPatcher" -> ResourceLimitPatcher( - k8sResource = resource, - container = patcherDefinition.getValueByKey("container"), - limitedResource = patcherDefinition.getValueByKey("limitedResource") - ) - "ResourceRequestPatcher" -> ResourceRequestPatcher( - k8sResource = resource, - container = patcherDefinition.getValueByKey("container"), - requestedResource = patcherDefinition.getValueByKey("requestedResource") - ) - "SchedulerNamePatcher" -> SchedulerNamePatcher( - k8sResource = resource - ) - "LabelPatcher" -> LabelPatcher( - k8sResource = resource, - variableName = patcherDefinition.getValueByKey("variableName") - ) - else -> throw IllegalArgumentException("Patcher type ${patcherDefinition.type} not found") + return try { + when (patcherDefinition.type) { + "ReplicaPatcher" -> ReplicaPatcher( + k8sResource = resource + ) + "NumNestedGroupsLoadGeneratorReplicaPatcher" -> NumNestedGroupsLoadGeneratorReplicaPatcher( + k8sResource = resource, + loadGenMaxRecords = patcherDefinition.config["loadGenMaxRecords"] !!, + numSensors = patcherDefinition.config["numSensors"] !! + ) + "NumSensorsLoadGeneratorReplicaPatcher" -> NumSensorsLoadGeneratorReplicaPatcher( + k8sResource = resource, + loadGenMaxRecords = patcherDefinition.config["loadGenMaxRecords"] !! + ) + "EnvVarPatcher" -> EnvVarPatcher( + k8sResource = resource, + container = patcherDefinition.config["container"] !!, + variableName = patcherDefinition.config["variableName"] !! + ) + "NodeSelectorPatcher" -> NodeSelectorPatcher( + k8sResource = resource, + variableName = patcherDefinition.config["variableName"] !! + ) + "ResourceLimitPatcher" -> ResourceLimitPatcher( + k8sResource = resource, + container = patcherDefinition.config["container"] !!, + limitedResource = patcherDefinition.config["limitedResource"] !! + ) + "ResourceRequestPatcher" -> ResourceRequestPatcher( + k8sResource = resource, + container = patcherDefinition.config["container"] !!, + requestedResource = patcherDefinition.config["requestedResource"] !! + ) + "SchedulerNamePatcher" -> SchedulerNamePatcher( + k8sResource = resource + ) + "LabelPatcher" -> LabelPatcher( + k8sResource = resource, + variableName = patcherDefinition.config["variableName"] !! + ) + else -> throw InvalidPatcherConfigurationException("Patcher type ${patcherDefinition.type} not found.") + } + } catch (e: Exception) { + throw InvalidPatcherConfigurationException("Could not create patcher with type ${patcherDefinition.type}" + + " Probably a required patcher argument was not specified." ) } } } diff --git a/theodolite-quarkus/src/main/kotlin/theodolite/util/PatcherDefinition.kt b/theodolite-quarkus/src/main/kotlin/theodolite/util/PatcherDefinition.kt index 508f6264ed6ae61e8e8260caf76914f23900ed60..62625b6dad5e09be216c6841100346eeb61371cd 100644 --- a/theodolite-quarkus/src/main/kotlin/theodolite/util/PatcherDefinition.kt +++ b/theodolite-quarkus/src/main/kotlin/theodolite/util/PatcherDefinition.kt @@ -21,23 +21,5 @@ class PatcherDefinition { lateinit var resource: String @JsonSerialize - lateinit var config: MutableList<Map<String, String>> - - fun getValueByKey(key: String): String { - val value = this.config - .filter { it["key"] == key } - .map { - try { - it.getValue("value") - } catch (e: Exception) { - throw InvalidPatcherConfigurationException("No value found for key $key.") - } - } - - return when { - value.isEmpty() -> throw InvalidPatcherConfigurationException("Required argument $key missing.") - value.size > 1 -> throw InvalidPatcherConfigurationException("Can not handle duplicate declaration for key $key.") - else -> value.first() - } - } + lateinit var config: MutableMap<String, String> } diff --git a/theodolite-quarkus/src/main/resources/operator/benchmarkCRD.yaml b/theodolite-quarkus/src/main/resources/operator/benchmarkCRD.yaml index 9d322021602488c828f2e3e8ba99c239a6ffac0e..56dec9bb76b0713bd5b0688014093ff54958abcb 100644 --- a/theodolite-quarkus/src/main/resources/operator/benchmarkCRD.yaml +++ b/theodolite-quarkus/src/main/resources/operator/benchmarkCRD.yaml @@ -55,16 +55,11 @@ spec: type: string default: "" config: - type: array - items: - type: object - properties: - key: - type: string - default: "" - value: - type: string - default: "" + type: object + additionalProperties: true + x-kubernetes-map-type: "granular" + default: + "": "" loadTypes: type: array minItems: 1 @@ -86,16 +81,11 @@ spec: type: string default: "" config: - type: array - items: - type: object - properties: - key: - type: string - default: "" - value: - type: string - default: "" + type: object + additionalProperties: true + x-kubernetes-map-type: "granular" + default: + "": "" kafkaConfig: type: object properties: diff --git a/theodolite-quarkus/src/main/resources/operator/example-benchmark-k8s-resource.yaml b/theodolite-quarkus/src/main/resources/operator/example-benchmark-k8s-resource.yaml index f6a7dc3335018708492dd2777fe3fc8ac8a8f2e8..0118fcd841bdc8f30e6de5a1b611094714bff54b 100644 --- a/theodolite-quarkus/src/main/resources/operator/example-benchmark-k8s-resource.yaml +++ b/theodolite-quarkus/src/main/resources/operator/example-benchmark-k8s-resource.yaml @@ -23,10 +23,12 @@ spec: - type: "EnvVarPatcher" resource: "uc1-load-generator-deployment.yaml" config: - - key: "container" - value: "workload-generator" - - key: "variableName" - value: "NUM_SENSORS" + container: "workload-generator" + variableName: "NUM_SENSORS" + - type: "NumSensorsLoadGeneratorReplicaPatcher" + resource: "uc1-load-generator-deployment.yaml" + config: + loadGenMaxRecords: "15000" kafkaConfig: bootstrapServer: "localhost:31290" topics: diff --git a/theodolite-quarkus/src/main/resources/operator/executionCRD.yaml b/theodolite-quarkus/src/main/resources/operator/executionCRD.yaml index 140140d095ad74781b51c0fef5dda1627933bd9c..bf2eb127995758d4ac15c34a57c8d59c9a1abbe3 100644 --- a/theodolite-quarkus/src/main/resources/operator/executionCRD.yaml +++ b/theodolite-quarkus/src/main/resources/operator/executionCRD.yaml @@ -96,16 +96,11 @@ spec: type: string default: "" config: - type: array - items: - type: object - properties: - key: - type: string - default: "" - value: - type: string - default: "" + type: object + additionalProperties: true + x-kubernetes-map-type: "granular" + default: + "": "" value: type: string status: