Explorar el Código

scale: sort containers by creation date to remove older ones first (#10571)

Signed-off-by: Nicolas De Loof <[email protected]>
Nicolas De loof hace 2 años
padre
commit
68c462e607
Se han modificado 1 ficheros con 4 adiciones y 0 borrados
  1. 4 0
      pkg/compose/convergence.go

+ 4 - 0
pkg/compose/convergence.go

@@ -19,6 +19,7 @@ package compose
 import (
 	"context"
 	"fmt"
+	"sort"
 	"strconv"
 	"strings"
 	"sync"
@@ -172,6 +173,9 @@ func (c *convergence) ensureService(ctx context.Context, project *types.Project,
 
 	eg, _ := errgroup.WithContext(ctx)
 
+	sort.Slice(containers, func(i, j int) bool {
+		return containers[i].Created < containers[j].Created
+	})
 	for i, container := range containers {
 		if i >= expected {
 			// Scale Down