Skip to content

Commit

Permalink
don't scale down when deploys are running
Browse files Browse the repository at this point in the history
  • Loading branch information
wardviaene committed Feb 20, 2018
1 parent 00ef3f5 commit 5a26140
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion api/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -899,6 +899,7 @@ func (c *Controller) processEcsMessage(message ecs.SNSPayloadEcs) error {
}
}
if hasFreeResourcesGlobal {
// check cooldown period
cooldownMin, err := strconv.ParseInt(util.GetEnv("AUTOSCALING_DOWN_COOLDOWN", "5"), 10, 64)
if err != nil {
return err
Expand All @@ -908,7 +909,19 @@ func (c *Controller) processEcsMessage(message ecs.SNSPayloadEcs) error {
if err != nil {
return err
}
if lastScalingOp == "no" {
// check whether there is a deploy running
var deployRunning bool
lastDeploys, err := s.GetDeploys("byDay", 50)
if err != nil {
return err
}
for _, v := range lastDeploys {
if v.Status == "running" {
deployRunning = true
}
}
// scale down if the cooldown period is not active and if there are no deploys currently running
if lastScalingOp == "no" && !deployRunning {
controllerLogger.Infof("Starting scaling down operation (cpu: %d >= %d, mem: %d >= %d", totalFreeCpu[hasFreeResourcesGlobalAZ], clusterCpuNeeded, totalFreeMemory[hasFreeResourcesGlobalAZ], clusterMemoryNeeded)
scalingOp = "down"
autoScalingGroupName, err := autoscaling.GetAutoScalingGroupByTag(clusterName)
Expand Down

0 comments on commit 5a26140

Please sign in to comment.