mirror of https://github.com/docker/compose.git
sort cpu values in conversion to fargate values
Signed-off-by: aiordache <anca.iordache@docker.com> Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
parent
94671e99e1
commit
716fd13690
|
@ -167,7 +167,7 @@ services:
|
|||
memory: 2043248M
|
||||
`)
|
||||
_, err := Backend{}.Convert(model)
|
||||
assert.ErrorContains(t, err, "The resources requested are not supported by ECS/Fargate")
|
||||
assert.ErrorContains(t, err, "the resources requested are not supported by ECS/Fargate")
|
||||
}
|
||||
|
||||
func TestLoadBalancerTypeNetwork(t *testing.T) {
|
||||
|
|
|
@ -2,6 +2,7 @@ package backend
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
@ -148,7 +149,14 @@ func toLimits(service types.ServiceConfig) (string, string, error) {
|
|||
return "", "", err
|
||||
}
|
||||
|
||||
for cpu, mem := range cpuToMem {
|
||||
var cpus []int64
|
||||
for k := range cpuToMem {
|
||||
cpus = append(cpus, k)
|
||||
}
|
||||
sort.Slice(cpus, func(i, j int) bool { return cpus[i] < cpus[j] })
|
||||
|
||||
for _, cpu := range cpus {
|
||||
mem := cpuToMem[cpu]
|
||||
if v <= cpu*MiB {
|
||||
for _, m := range mem {
|
||||
if limits.MemoryBytes <= m*MiB {
|
||||
|
@ -159,7 +167,7 @@ func toLimits(service types.ServiceConfig) (string, string, error) {
|
|||
}
|
||||
}
|
||||
}
|
||||
return "", "", fmt.Errorf("The resources requested are not supported by ECS/Fargate")
|
||||
return "", "", fmt.Errorf("the resources requested are not supported by ECS/Fargate")
|
||||
}
|
||||
|
||||
func toContainerReservation(service types.ServiceConfig) (string, int, error) {
|
||||
|
|
Loading…
Reference in New Issue