Merge pull request #29 from gianarb/hotfix/avoid-scaling-down

avoiding scale under 1, scale up services at 0
This commit is contained in:
Gianluca Arbezzano 2017-08-08 21:05:05 +02:00 committed by GitHub
commit 80acddce1d

View File

@ -96,7 +96,7 @@ func (p SwarmProvider) Scale(serviceId string, target int, direction bool) error
// This function validate if a request is acceptable or not.
func (p *SwarmProvider) isAcceptable(tasks []swarm.Task, target int, direction bool) error {
if p.calculateActiveTasks(tasks) < target && direction == false {
if p.calculateActiveTasks(tasks) < target || p.calculateActiveTasks(tasks) < 2 && direction == false {
return errors.New(fmt.Sprintf("I can not scale down because it has only %d running.", target))
}
return nil