mirror of https://github.com/docker/compose.git
				
				
				
			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 (
 | 
			
		||||
	"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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue