mirror of https://github.com/docker/cli.git
Support ulimits in docker stack deploy
This is related to moby/moby 40639. Signed-off-by: Albin Kerouanton <albin@akerouanton.name> Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
a9158bdc50
commit
940907951b
|
@ -14,6 +14,7 @@ import (
|
|||
"github.com/docker/docker/api/types/swarm"
|
||||
"github.com/docker/docker/api/types/versions"
|
||||
"github.com/docker/docker/client"
|
||||
"github.com/docker/go-units"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
|
@ -151,6 +152,7 @@ func Service(
|
|||
Sysctls: service.Sysctls,
|
||||
CapabilityAdd: capAdd,
|
||||
CapabilityDrop: capDrop,
|
||||
Ulimits: convertUlimits(service.Ulimits),
|
||||
},
|
||||
LogDriver: logDriver,
|
||||
Resources: resources,
|
||||
|
@ -680,3 +682,30 @@ func convertCredentialSpec(namespace Namespace, spec composetypes.CredentialSpec
|
|||
}
|
||||
return &swarmCredSpec, nil
|
||||
}
|
||||
|
||||
func convertUlimits(origUlimits map[string]*composetypes.UlimitsConfig) []*units.Ulimit {
|
||||
newUlimits := make(map[string]*units.Ulimit)
|
||||
for name, u := range origUlimits {
|
||||
if u.Single != 0 {
|
||||
newUlimits[name] = &units.Ulimit{
|
||||
Name: name,
|
||||
Soft: int64(u.Single),
|
||||
Hard: int64(u.Single),
|
||||
}
|
||||
} else {
|
||||
newUlimits[name] = &units.Ulimit{
|
||||
Name: name,
|
||||
Soft: int64(u.Soft),
|
||||
Hard: int64(u.Hard),
|
||||
}
|
||||
}
|
||||
}
|
||||
var ulimits []*units.Ulimit
|
||||
for _, ulimit := range newUlimits {
|
||||
ulimits = append(ulimits, ulimit)
|
||||
}
|
||||
sort.SliceStable(ulimits, func(i, j int) bool {
|
||||
return ulimits[i].Name < ulimits[j].Name
|
||||
})
|
||||
return ulimits
|
||||
}
|
||||
|
|
|
@ -23,7 +23,6 @@ var UnsupportedProperties = []string{
|
|||
"restart",
|
||||
"security_opt",
|
||||
"shm_size",
|
||||
"ulimits",
|
||||
"userns_mode",
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue