fix cpu parsing logic (#10808)

pull/10838/head
Prabhat Khera 2023-12-12 15:35:36 +13:00 committed by GitHub
parent 6ff6fd7f75
commit 32d8dc311b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 0 deletions

View File

@ -28,9 +28,17 @@ class KubernetesResourceReservationHelper {
static parseCPU(cpu) { static parseCPU(cpu) {
let res = parseInt(cpu, 10); let res = parseInt(cpu, 10);
if (_.endsWith(cpu, 'm')) { if (_.endsWith(cpu, 'm')) {
// milli
res /= 1000; res /= 1000;
} else if (_.endsWith(cpu, 'u')) {
// micro
res /= 1000000;
} else if (_.endsWith(cpu, 'n')) { } else if (_.endsWith(cpu, 'n')) {
// nano
res /= 1000000000; res /= 1000000000;
} else if (_.endsWith(cpu, 'p')) {
// pico
res /= 1000000000000;
} }
return res; return res;
} }