Skip to content

Commit

Permalink
Merge pull request openshift#8763 from spadgett/unflake-scaling-for-dan
Browse files Browse the repository at this point in the history
Merged by openshift-bot
  • Loading branch information
OpenShift Bot committed May 5, 2016
2 parents fb6ac82 + 116170e commit 436a4de
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
13 changes: 11 additions & 2 deletions assets/app/scripts/directives/overviewDeployment.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,13 @@ angular.module('openshiftConsole')
},
templateUrl: 'views/_overview-deployment.html',
controller: function($scope) {
var scaleRequestPending = false;

$scope.$watch("rc.spec.replicas", function() {
$scope.desiredReplicas = null;
// Only reset desiredReplicas if we've already requested that value.
if (!scaleRequestPending) {
$scope.desiredReplicas = null;
}
});

var updateHPAWarnings = function() {
Expand All @@ -56,6 +61,8 @@ angular.module('openshiftConsole')

// Debounce scaling so multiple clicks within 500 milliseconds only result in one request.
var scale = _.debounce(function () {
scaleRequestPending = false;

if (!angular.isNumber($scope.desiredReplicas)) {
return;
}
Expand All @@ -76,7 +83,7 @@ angular.module('openshiftConsole')
} else {
DeploymentsService.scaleRC($scope.rc, $scope.desiredReplicas).then(_.noop, showScalingError);
}
}, 500);
}, 1000);

$scope.viewPodsForDeployment = function(deployment) {
if (hashSizeFilter($scope.pods) === 0) {
Expand All @@ -94,6 +101,7 @@ angular.module('openshiftConsole')
$scope.desiredReplicas = $scope.getDesiredReplicas();
$scope.desiredReplicas++;
scale();
scaleRequestPending = true;
};

$scope.scaleDown = function() {
Expand Down Expand Up @@ -132,6 +140,7 @@ angular.module('openshiftConsole')
// getDesiredReplicas() again.
$scope.desiredReplicas = $scope.getDesiredReplicas() - 1;
scale();
scaleRequestPending = true;
});

return;
Expand Down
23 changes: 12 additions & 11 deletions pkg/assets/bindata.go
Original file line number Diff line number Diff line change
Expand Up @@ -7034,33 +7034,34 @@ alerts:"="
},
templateUrl:"views/_overview-deployment.html",
controller:[ "$scope", function(b) {
var c = !1;
b.$watch("rc.spec.replicas", function() {
b.desiredReplicas = null;
c || (b.desiredReplicas = null);
});
var c = function() {
var g = function() {
f.getHPAWarnings(b.rc, b.hpa, b.limitRanges, b.project).then(function(a) {
b.hpaWarnings = _.map(a, function(a) {
return _.escape(a.message);
}).join("<br>");
});
};
b.$watchGroup([ "limitRanges", "hpa", "project" ], c), b.$watch("rc.spec.template.spec.containers", c, !0);
var g = _.debounce(function() {
if (angular.isNumber(b.desiredReplicas)) {
var c = function(c) {
b.$watchGroup([ "limitRanges", "hpa", "project" ], g), b.$watch("rc.spec.template.spec.containers", g, !0);
var k = _.debounce(function() {
if (c = !1, angular.isNumber(b.desiredReplicas)) {
var d = function(c) {
b.alerts = b.alerts || {}, b.desiredReplicas = null, b.alerts.scale = {
type:"error",
message:"An error occurred scaling the deployment.",
details:a("getErrorDetails")(c)
};
};
b.deploymentConfig ? e.scaleDC(b.deploymentConfig, b.desiredReplicas).then(_.noop, c) :e.scaleRC(b.rc, b.desiredReplicas).then(_.noop, c);
b.deploymentConfig ? e.scaleDC(b.deploymentConfig, b.desiredReplicas).then(_.noop, d) :e.scaleRC(b.rc, b.desiredReplicas).then(_.noop, d);
}
}, 500);
}, 1e3);
b.viewPodsForDeployment = function(a) {
0 !== i(b.pods) && h.toPodsForDeployment(a);
}, b.scaleUp = function() {
b.scalable && (b.desiredReplicas = b.getDesiredReplicas(), b.desiredReplicas++, g());
b.scalable && (b.desiredReplicas = b.getDesiredReplicas(), b.desiredReplicas++, k(), c = !0);
}, b.scaleDown = function() {
if (b.scalable && (b.desiredReplicas = b.getDesiredReplicas(), 0 !== b.desiredReplicas)) {
if (1 === b.desiredReplicas) {
Expand All @@ -7078,10 +7079,10 @@ return j(b.rc) ? "deployment" :"replication controller";
}
});
return void a.result.then(function() {
b.desiredReplicas = b.getDesiredReplicas() - 1, g();
b.desiredReplicas = b.getDesiredReplicas() - 1, k(), c = !0;
});
}
b.desiredReplicas--, g();
b.desiredReplicas--, k();
}
}, b.getDesiredReplicas = function() {
return angular.isDefined(b.desiredReplicas) && null !== b.desiredReplicas ? b.desiredReplicas :b.rc && b.rc.spec && angular.isDefined(b.rc.spec.replicas) ? b.rc.spec.replicas :1;
Expand Down

0 comments on commit 436a4de

Please sign in to comment.