Add ability to set cgroups freezer
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
This commit is contained in:
parent
b6344f992e
commit
6c3fd65a5c
2 changed files with 15 additions and 4 deletions
|
@ -20,6 +20,7 @@ type Cgroup struct {
|
||||||
CpuQuota int64 `json:"cpu_quota,omitempty"` // CPU hardcap limit (in usecs). Allowed cpu time in a given period.
|
CpuQuota int64 `json:"cpu_quota,omitempty"` // CPU hardcap limit (in usecs). Allowed cpu time in a given period.
|
||||||
CpuPeriod int64 `json:"cpu_period,omitempty"` // CPU period to be used for hardcapping (in usecs). 0 to use system default.
|
CpuPeriod int64 `json:"cpu_period,omitempty"` // CPU period to be used for hardcapping (in usecs). 0 to use system default.
|
||||||
CpusetCpus string `json:"cpuset_cpus,omitempty"` // CPU to use
|
CpusetCpus string `json:"cpuset_cpus,omitempty"` // CPU to use
|
||||||
|
Freezer string `json:"freezer,omitempty"` // set the freeze value for the process
|
||||||
|
|
||||||
UnitProperties [][2]string `json:"unit_properties,omitempty"` // systemd unit properties
|
UnitProperties [][2]string `json:"unit_properties,omitempty"` // systemd unit properties
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,21 +2,31 @@ package fs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/dotcloud/docker/pkg/cgroups"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/dotcloud/docker/pkg/cgroups"
|
||||||
)
|
)
|
||||||
|
|
||||||
type freezerGroup struct {
|
type freezerGroup struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *freezerGroup) Set(d *data) error {
|
func (s *freezerGroup) Set(d *data) error {
|
||||||
// we just want to join this group even though we don't set anything
|
dir, err := d.join("freezer")
|
||||||
if _, err := d.join("freezer"); err != nil && err != cgroups.ErrNotFound {
|
if err != nil {
|
||||||
return err
|
if err != cgroups.ErrNotFound {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if d.c.Freezer != "" {
|
||||||
|
if err := writeFile(dir, "freezer.state", d.c.Freezer); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue