From a49f1c9559b9e26e01b93ec3b1030268e1692336 Mon Sep 17 00:00:00 2001 From: Mike Lang Date: Thu, 16 Feb 2017 15:37:50 -0800 Subject: [PATCH] ECS service controls: Don't allow scale down below 1 as currently this would make it disappear (#2085). See also https://github.com/weaveworks/scope/pull/2197#discussion_r100424800 --- probe/awsecs/client.go | 4 ++-- probe/awsecs/reporter.go | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/probe/awsecs/client.go b/probe/awsecs/client.go index e57a7358d8..d1ad708902 100644 --- a/probe/awsecs/client.go +++ b/probe/awsecs/client.go @@ -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, diff --git a/probe/awsecs/reporter.go b/probe/awsecs/reporter.go index bddcac81ca..5e4849ce0a 100644 --- a/probe/awsecs/reporter.go +++ b/probe/awsecs/reporter.go @@ -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))