Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix Sets the requests equals to limits. #57

Merged
merged 2 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading