Rework cpuShares into cpuQuota
cpuShares is the relative weight wrt other apps. This is used when there is contention for CPU. If we want this, maybe we implement a UI where we show all the apps and let the user re-order them. As it stands, it is confusing. cpuQuota is a more straightforward "hard limit" of the CPU% that you want the app to consume. Can be tested with : stress -c 8 -t 20s
This commit is contained in:
@@ -1014,18 +1014,16 @@
|
||||
<hr/>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<form role="form" name="resourcesForm" ng-submit="resources.submitCpuShares()" autocomplete="off">
|
||||
<form role="form" name="resourcesForm" ng-submit="resources.submitCpuQuota()" autocomplete="off">
|
||||
<fieldset>
|
||||
<div class="form-group">
|
||||
<label class="control-label" for="cpuShares">{{ 'app.resources.cpu.title' | tr }} <sup><a ng-href="https://docs.cloudron.io/apps/#cpu-shares" class="help" target="_blank"><i class="fa fa-question-circle"></i></a></sup> : <b>{{ (resources.cpuShares * 100 / 1024 | number:0) + ' %' }}</b></label>
|
||||
<label class="control-label" for="cpuQuota">{{ 'app.resources.cpu.title' | tr }} <sup><a ng-href="https://docs.cloudron.io/apps/#cpu-quota" class="help" target="_blank"><i class="fa fa-question-circle"></i></a></sup> : <b>{{ resources.cpuQuota + ' %' }}</b></label>
|
||||
<p>{{ 'app.resources.cpu.description' | tr }}</p>
|
||||
<input type="range" id="cpuShares" ng-model="resources.cpuShares" step="32" min="32" max="1024" list="cpuSharesTicks" />
|
||||
<datalist id="cpuSharesTicks">
|
||||
<option value="32"></option>
|
||||
<option value="256"></option>
|
||||
<option value="512"></option>
|
||||
<option value="768"></option>
|
||||
<option value="1024"></option>
|
||||
<input type="range" id="cpuQuota" ng-model="resources.cpuQuota" step="1" min="1" max="100"/>
|
||||
<datalist id="cpuQuotaTicks">
|
||||
<option value="25"></option>
|
||||
<option value="50"></option>
|
||||
<option value="75"></option>
|
||||
</datalist>
|
||||
</div>
|
||||
</fieldset>
|
||||
@@ -1034,7 +1032,7 @@
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-12 text-right">
|
||||
<button class="btn btn-outline btn-primary pull-right" ng-click="resources.submitCpuShares()" ng-disabled="resources.cpuShares === resources.currentCpuShares || resourcesForm.$invalid || resources.busy || app.error || app.taskId" tooltip-enable="app.error || app.taskId" uib-tooltip="{{ app.error ? 'App is in error state' : 'App is busy' }}">{{ 'app.resources.cpu.setAction' | tr }}</button>
|
||||
<button class="btn btn-outline btn-primary pull-right" ng-click="resources.submitCpuQuota()" ng-disabled="resources.cpuQuota === resources.currentCpuQuota || resourcesForm.$invalid || resources.busy || app.error || app.taskId" tooltip-enable="app.error || app.taskId" uib-tooltip="{{ app.error ? 'App is in error state' : 'App is busy' }}">{{ 'app.resources.cpu.setAction' | tr }}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -543,8 +543,8 @@ angular.module('Application').controller('AppController', ['$scope', '$location'
|
||||
memoryLimit: 0, // RAM
|
||||
memoryTicks: [],
|
||||
|
||||
currentCpuShares: 0,
|
||||
cpuShares: 0,
|
||||
currentCpuQuota: 0,
|
||||
cpuQuota: 0,
|
||||
|
||||
show: function () {
|
||||
var app = $scope.app;
|
||||
@@ -569,7 +569,7 @@ angular.module('Application').controller('AppController', ['$scope', '$location'
|
||||
|
||||
// for firefox widget update
|
||||
$timeout(function() {
|
||||
$scope.resources.currentCpuShares = $scope.resources.cpuShares = app.cpuShares;
|
||||
$scope.resources.currentCpuQuota = $scope.resources.cpuQuota = app.cpuQuota;
|
||||
$scope.resources.memoryLimit = $scope.resources.currentMemoryLimit;
|
||||
$scope.resources.busy = false;
|
||||
}, 500);
|
||||
@@ -600,14 +600,14 @@ angular.module('Application').controller('AppController', ['$scope', '$location'
|
||||
});
|
||||
},
|
||||
|
||||
submitCpuShares: function () {
|
||||
submitCpuQuota: function () {
|
||||
$scope.resources.busy = true;
|
||||
$scope.resources.error = {};
|
||||
|
||||
Client.configureApp($scope.app.id, 'cpu_shares', { cpuShares: parseInt($scope.resources.cpuShares) }, function (error) {
|
||||
Client.configureApp($scope.app.id, 'cpu_quota', { cpuQuota: parseInt($scope.resources.cpuQuota) }, function (error) {
|
||||
if (error) return Client.error(error);
|
||||
|
||||
$scope.resources.currentCpuShares = $scope.resources.cpuShares;
|
||||
$scope.resources.currentCpuQuota = $scope.resources.cpuQuota;
|
||||
|
||||
refreshApp($scope.app.id, function (error) {
|
||||
if (error) return Client.error(error);
|
||||
|
||||
Reference in New Issue
Block a user