mirror of
https://github.com/docker/compose.git
synced 2025-07-22 21:24:38 +02:00
scale: sort containers by creation date to remove older ones first (#10571)
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
parent
916aac6c27
commit
68c462e607
@ -19,6 +19,7 @@ package compose
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
@ -172,6 +173,9 @@ func (c *convergence) ensureService(ctx context.Context, project *types.Project,
|
|||||||
|
|
||||||
eg, _ := errgroup.WithContext(ctx)
|
eg, _ := errgroup.WithContext(ctx)
|
||||||
|
|
||||||
|
sort.Slice(containers, func(i, j int) bool {
|
||||||
|
return containers[i].Created < containers[j].Created
|
||||||
|
})
|
||||||
for i, container := range containers {
|
for i, container := range containers {
|
||||||
if i >= expected {
|
if i >= expected {
|
||||||
// Scale Down
|
// Scale Down
|
||||||
|
Loading…
x
Reference in New Issue
Block a user