Skip to content

Commit

Permalink
feat(amazon): Support passing a capacity constraint during resize (#4545
Browse files Browse the repository at this point in the history
)

`clouddriver` can enforce that capacity of the server group being
resized has not changed in the background.

This addresses situations where autoscaling has occurred in the
background and subsequently been "undone" by a concurrent resize operation.
  • Loading branch information
ajordens committed Nov 29, 2017
1 parent 23d0a77 commit 773833f
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 7 deletions.
6 changes: 5 additions & 1 deletion app/scripts/modules/amazon/src/help/amazon.help.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,11 @@ const helpContents: {[key: string]: string} = {
'aws.targetGroup.attributes.deregistrationDelay': 'The amount of time for Elastic Load Balancing to wait before changing the state of a deregistering target from draining to unused. The range is 0-3600 seconds. The default value is 300 seconds.',
'aws.targetGroup.attributes.stickinessEnabled': ' Indicates whether sticky sessions are enabled.',
'aws.targetGroup.attributes.stickinessType': 'The type of sticky sessions. The only current possible value is <code>lb_cookie</code>.',
'aws.targetGroup.attributes.stickinessDuration': 'The time period, in seconds, during which requests from a client should be routed to the same target. After this time period expires, the load balancer-generated cookie is considered stale. The range is 1 second to 1 week (604800 seconds). The default value is 1 day (86400 seconds).'
'aws.targetGroup.attributes.stickinessDuration': 'The time period, in seconds, during which requests from a client should be routed to the same target. After this time period expires, the load balancer-generated cookie is considered stale. The range is 1 second to 1 week (604800 seconds). The default value is 1 day (86400 seconds).',
'aws.serverGroup.capacityConstraint': `
<p>Ensures that the capacity of this server group has not changed in the background (i.e. due to autoscaling activity).</p>
<p>If the capacity has changed, this resize operation will be rejected.</p>`,

};

export const AMAZON_HELP = 'spinnaker.amazon.help.contents';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ module.exports = angular.module('spinnaker.amazon.serverGroup.details.resize.con

$scope.command = angular.copy($scope.currentSize);
$scope.command.advancedMode = serverGroup.asg.minSize !== serverGroup.asg.maxSize;
$scope.command.constraints = {
capacity: {
min: serverGroup.asg.minSize,
max: serverGroup.asg.maxSize,
desired: serverGroup.asg.desiredCapacity
}
};

if (application && application.attributes) {
if (application.attributes.platformHealthOnlyShowOverride && application.attributes.platformHealthOnly) {
Expand All @@ -35,6 +42,20 @@ module.exports = angular.module('spinnaker.amazon.serverGroup.details.resize.con
$scope.command.platformHealthOnlyShowOverride = application.attributes.platformHealthOnlyShowOverride;
}

this.toggleCapacityConstraint = function () {
if ($scope.command.constraints.capacity) {
$scope.command.constraints = {};
} else {
$scope.command.constraints = {
capacity: {
min: serverGroup.asg.minSize,
max: serverGroup.asg.maxSize,
desired: serverGroup.asg.desiredCapacity
}
};
}
};

this.isValid = function () {
var command = $scope.command;
if (!$scope.verification.verified) {
Expand Down Expand Up @@ -63,6 +84,7 @@ module.exports = angular.module('spinnaker.amazon.serverGroup.details.resize.con
var submitMethod = function() {
return serverGroupWriter.resizeServerGroup(serverGroup, application, {
capacity: capacity,
constraints: $scope.command.constraints,
interestingHealthProviderNames: $scope.command.interestingHealthProviderNames,
reason: $scope.command.reason,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,26 @@ <h3>Resize {{serverGroup.name}}</h3>
<div class="form-horizontal">
<aws-resize-capacity command="command" current-size="currentSize"></aws-resize-capacity>
</div>
<div class="row" ng-if="command.platformHealthOnlyShowOverride">
<div class="row">
<div class="col-sm-10 col-sm-offset-1">
<platform-health-override command="command"
platform-health-type="'Amazon'"
show-help-details="true">
</platform-health-override>
<div class="checkbox">
<label>
<input type="checkbox"
ng-checked="command.constraints.capacity"
ng-click="ctrl.toggleCapacityConstraint()"/>
Enforce Capacity Constraint
</label>
<help-field key="aws.serverGroup.capacityConstraint"></help-field>
</div>
<div ng-if="command.platformHealthOnlyShowOverride">
<platform-health-override command="command"
platform-health-type="'Amazon'"
show-help-details="true">
</platform-health-override>
</div>
</div>
</div>
<task-reason command="command"></task-reason>

</div>
<aws-footer action="ctrl.resize()"
cancel="ctrl.cancel()"
Expand Down

0 comments on commit 773833f

Please sign in to comment.