mirror of
https://github.com/containers/podman.git
synced 2025-10-19 12:12:36 +08:00
Merge pull request #3583 from giuseppe/ulimit-host-not-set
spec: simplify handling of --ulimit host
This commit is contained in:
@ -20,12 +20,6 @@ import (
|
|||||||
|
|
||||||
const cpuPeriod = 100000
|
const cpuPeriod = 100000
|
||||||
|
|
||||||
type systemUlimit struct {
|
|
||||||
name string
|
|
||||||
max uint64
|
|
||||||
cur uint64
|
|
||||||
}
|
|
||||||
|
|
||||||
func getAvailableGids() (int64, error) {
|
func getAvailableGids() (int64, error) {
|
||||||
idMap, err := user.ParseIDMapFile("/proc/self/gid_map")
|
idMap, err := user.ParseIDMapFile("/proc/self/gid_map")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -585,13 +579,7 @@ func addRlimits(config *CreateConfig, g *generate.Generator) error {
|
|||||||
if len(config.Resources.Ulimit) != 1 {
|
if len(config.Resources.Ulimit) != 1 {
|
||||||
return errors.New("ulimit can use host only once")
|
return errors.New("ulimit can use host only once")
|
||||||
}
|
}
|
||||||
hostLimits, err := getHostRlimits()
|
g.Config.Process.Rlimits = nil
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
for _, i := range hostLimits {
|
|
||||||
g.AddProcessRlimits(i.name, i.max, i.cur)
|
|
||||||
}
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,42 +0,0 @@
|
|||||||
//+build linux
|
|
||||||
|
|
||||||
package createconfig
|
|
||||||
|
|
||||||
import (
|
|
||||||
"syscall"
|
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
)
|
|
||||||
|
|
||||||
type systemRlimit struct {
|
|
||||||
name string
|
|
||||||
value int
|
|
||||||
}
|
|
||||||
|
|
||||||
var systemLimits = []systemRlimit{
|
|
||||||
{"RLIMIT_AS", syscall.RLIMIT_AS},
|
|
||||||
{"RLIMIT_CORE", syscall.RLIMIT_CORE},
|
|
||||||
{"RLIMIT_CPU", syscall.RLIMIT_CPU},
|
|
||||||
{"RLIMIT_DATA", syscall.RLIMIT_DATA},
|
|
||||||
{"RLIMIT_FSIZE", syscall.RLIMIT_FSIZE},
|
|
||||||
{"RLIMIT_NOFILE", syscall.RLIMIT_NOFILE},
|
|
||||||
{"RLIMIT_STACK", syscall.RLIMIT_STACK},
|
|
||||||
}
|
|
||||||
|
|
||||||
func getHostRlimits() ([]systemUlimit, error) {
|
|
||||||
ret := []systemUlimit{}
|
|
||||||
for _, i := range systemLimits {
|
|
||||||
var l syscall.Rlimit
|
|
||||||
if err := syscall.Getrlimit(i.value, &l); err != nil {
|
|
||||||
return nil, errors.Wrapf(err, "cannot read limits for %s", i.name)
|
|
||||||
}
|
|
||||||
s := systemUlimit{
|
|
||||||
name: i.name,
|
|
||||||
max: l.Max,
|
|
||||||
cur: l.Cur,
|
|
||||||
}
|
|
||||||
ret = append(ret, s)
|
|
||||||
}
|
|
||||||
return ret, nil
|
|
||||||
|
|
||||||
}
|
|
@ -1,7 +0,0 @@
|
|||||||
//+build !linux
|
|
||||||
|
|
||||||
package createconfig
|
|
||||||
|
|
||||||
func getHostRlimits() ([]systemUlimit, error) {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
Reference in New Issue
Block a user