operator: use limits route to get the max memory app can use

This commit is contained in:
Girish Ramakrishnan
2021-09-21 22:29:05 -07:00
parent b493355cbc
commit 26e9589842
2 changed files with 11 additions and 2 deletions
+2 -2
View File
@@ -544,13 +544,13 @@ angular.module('Application').controller('AppController', ['$scope', '$location'
$scope.resources.memoryLimit = $scope.resources.currentMemoryLimit;
$scope.resources.currentCpuShares = $scope.resources.cpuShares = app.cpuShares;
Client.memory(function (error, memory) {
Client.getAppLimits(app.id, function (error, limits) {
if (error) return console.error(error);
// create ticks starting from manifest memory limit. the memory limit here is currently split into ram+swap (and thus *2 below)
// TODO: the *2 will overallocate since 4GB is max swap that cloudron itself allocates
$scope.resources.memoryTicks = [];
var npow2 = Math.pow(2, Math.ceil(Math.log(memory.memory)/Math.log(2)));
var npow2 = Math.pow(2, Math.ceil(Math.log(limits.memory.memory)/Math.log(2)));
for (var i = 256; i <= (npow2*2/1024/1024); i *= 2) {
if (i >= (app.manifest.memoryLimit/1024/1024 || 0)) $scope.resources.memoryTicks.push(i * 1024 * 1024);
}