fix(container-creation): allow resetting to unlimited (#4138)

* fix(container-creation): allow resetting to unlimited

* fix(container-creation): refactor for readability
pull/4147/head
itsconquest 2020-08-04 11:14:59 +12:00 committed by GitHub
parent 4d5836138b
commit 490b7ad26f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 7 deletions

View File

@ -316,19 +316,21 @@ angular.module('portainer.docker').controller('CreateContainerController', [
function prepareResources(config) {
// Memory Limit - Round to 0.125
var memoryLimit = (Math.round($scope.formValues.MemoryLimit * 8) / 8).toFixed(3);
memoryLimit *= 1024 * 1024;
if (memoryLimit > 0) {
if ($scope.formValues.MemoryLimit >= 0) {
var memoryLimit = (Math.round($scope.formValues.MemoryLimit * 8) / 8).toFixed(3);
memoryLimit *= 1024 * 1024;
config.HostConfig.Memory = memoryLimit;
}
// Memory Resevation - Round to 0.125
var memoryReservation = (Math.round($scope.formValues.MemoryReservation * 8) / 8).toFixed(3);
memoryReservation *= 1024 * 1024;
if (memoryReservation > 0) {
if ($scope.formValues.MemoryReservation >= 0) {
var memoryReservation = (Math.round($scope.formValues.MemoryReservation * 8) / 8).toFixed(3);
memoryReservation *= 1024 * 1024;
config.HostConfig.MemoryReservation = memoryReservation;
}
// CPU Limit
if ($scope.formValues.CpuLimit > 0) {
if ($scope.formValues.CpuLimit >= 0) {
config.HostConfig.NanoCpus = $scope.formValues.CpuLimit * 1000000000;
}
}