Merge pull request #893 from Dokploy/510-fractional-cpu-reservation-and-limit

refactor: remove calculation and pass resources as the docker api expect
This commit is contained in:
Mauricio Siu
2024-12-14 20:40:16 -06:00
committed by GitHub

View File

@@ -317,16 +317,12 @@ export const calculateResources = ({
}: Resources): ResourceRequirements => {
return {
Limits: {
MemoryBytes: memoryLimit ? memoryLimit * 1024 * 1024 : undefined,
NanoCPUs: cpuLimit ? (cpuLimit || 1) * 1000 * 1000 * 1000 : undefined,
MemoryBytes: memoryLimit ?? undefined,
NanoCPUs: cpuLimit ?? undefined,
},
Reservations: {
MemoryBytes: memoryReservation
? (memoryReservation || 1) * 1024 * 1024
: undefined,
NanoCPUs: cpuReservation
? (cpuReservation || 1) * 1000 * 1000 * 1000
: undefined,
MemoryBytes: memoryReservation ?? undefined,
NanoCPUs: cpuReservation ?? undefined,
},
};
};