Skip to content

Commit

Permalink
Merge pull request #57 from elixir-cloud-aai/fix-for-rahti
Browse files Browse the repository at this point in the history
fix Sets the requests equals to limits.
  • Loading branch information
trispera authored Aug 7, 2024
2 parents eceb7b4 + 61aa043 commit 12754b8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ public V1Job fromTesExecutorToK8sJob(String generatedTaskId, String tesTaskName,
executor.getEnv().forEach((key, value) -> container.addEnvItem(new V1EnvVar().name(key).value(value)));
}
container.setWorkingDir(executor.getWorkdir());
Optional.ofNullable(resources).map(TesResources::getCpuCores).ifPresent(cpuCores -> container.getResources().putLimitsItem(RESOURCE_CPU_KEY, new QuantityFormatter().parse(cpuCores.toString())));
Optional.ofNullable(resources).map(TesResources::getCpuCores).ifPresent(cpuCores -> container.getResources().putRequestsItem(RESOURCE_CPU_KEY, new QuantityFormatter().parse(cpuCores.toString())));
// Limit number of decimals to 6
Optional.ofNullable(resources).map(TesResources::getRamGb).ifPresent(ramGb -> container.getResources().putRequestsItem(RESOURCE_MEM_KEY, new QuantityFormatter().parse(String.format("%.6f",ramGb)+RESOURCE_MEM_UNIT)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ public void fromTesTaskToK8sConfigMap() throws IOException {
taskMasterInputJson.extractingJsonPathStringValue("executors[1].spec.template.spec.containers[0].name").isEqualTo("task-35605447-ex-01");

taskMasterInputJson.extractingJsonPathArrayValue("executors[*].spec.template.spec.restartPolicy").containsOnly("Never").hasSize(2);
taskMasterInputJson.extractingJsonPathArrayValue("executors[*].spec.template.spec.containers[0].resources.limits.cpu").containsOnly("4").hasSize(2);
taskMasterInputJson.extractingJsonPathArrayValue("executors[*].spec.template.spec.containers[0].resources.requests.cpu").containsOnly("4").hasSize(2);
taskMasterInputJson.extractingJsonPathArrayValue("executors[*].spec.template.spec.containers[0].resources.requests.memory").containsOnly("16106127360").hasSize(2);

Expand Down
6 changes: 6 additions & 0 deletions src/test/resources/fromTesToK8s/taskmaster_param.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@
"requests": {
"cpu": "4",
"memory": "16106127360"
},
"limits": {
"cpu": "4"
}
},
"volumeMounts": [
Expand Down Expand Up @@ -143,6 +146,9 @@
"requests": {
"cpu": "4",
"memory": "16106127360"
},
"limits": {
"cpu": "4"
}
},
"workingDir": "/starthere",
Expand Down

0 comments on commit 12754b8

Please sign in to comment.