Skip to content

Commit

Permalink
ECS service controls: Don't allow scale down below 1
Browse files Browse the repository at this point in the history
as currently this would make it disappear (#2085).
See also #2197 (comment)
  • Loading branch information
ekimekim committed Feb 17, 2017
1 parent 5a47717 commit a49f1c9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions probe/awsecs/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,8 +396,8 @@ func (c ecsClientImpl) ScaleService(serviceName string, amount int) error {
}

newCount := service.DesiredCount + int64(amount)
if newCount < 0 {
return fmt.Errorf("Cannot reduce count below zero")
if newCount < 1 {
return fmt.Errorf("Cannot reduce count below one")
}
_, err := c.client.UpdateService(&ecs.UpdateServiceInput{
Cluster: &c.cluster,
Expand Down
7 changes: 6 additions & 1 deletion probe/awsecs/reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,12 @@ func (r Reporter) Tag(rpt report.Report) (report.Report, error) {
ServiceDesiredCount: fmt.Sprintf("%d", service.DesiredCount),
ServiceRunningCount: fmt.Sprintf("%d", service.RunningCount),
report.ControlProbeID: r.probeID,
}).WithLatestActiveControls(ScaleUp, ScaleDown))
}).WithLatestControls(map[string]report.NodeControlData{
ScaleUp: {Dead: false},
// We've decided for now to disable ScaleDown when only 1 task is desired,
// since scaling down to 0 would cause the service to disappear (#2085)
ScaleDown: {Dead: service.DesiredCount <= 1},
}))
}
log.Debugf("Created %v ECS service nodes", len(ecsInfo.Services))

Expand Down

0 comments on commit a49f1c9

Please sign in to comment.