mirror of
https://github.com/clearlinux/docker.git
synced 2026-09-06 05:31:47 +00:00
Integrating systemd freeze functionality.
This pulls together #6061 and #6125 Docker-DCO-1.1-Signed-off-by: Chris Alfonso <calfonso@redhat.com> (github: calfonso)
This commit is contained in:
@@ -27,7 +27,6 @@ var actions = map[string]Action{
|
||||
"cgroups.memory_reservation": memoryReservation, // set the memory reservation
|
||||
"cgroups.memory_swap": memorySwap, // set the memory swap limit
|
||||
"cgroups.cpuset.cpus": cpusetCpus, // set the cpus used
|
||||
"cgroups.freezer": freezer, // set the frozen/thaw state
|
||||
|
||||
"systemd.slice": systemdSlice, // set parent Slice used for systemd unit
|
||||
|
||||
@@ -36,16 +35,6 @@ var actions = map[string]Action{
|
||||
"fs.readonly": readonlyFs, // make the rootfs of the container read only
|
||||
}
|
||||
|
||||
func freezer(container *libcontainer.Container, context interface{}, value string) error {
|
||||
if container.Cgroups == nil {
|
||||
return fmt.Errorf("cannot set cgroups when they are disabled")
|
||||
}
|
||||
|
||||
container.Cgroups.Freezer = value
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func cpusetCpus(container *libcontainer.Container, context interface{}, value string) error {
|
||||
if container.Cgroups == nil {
|
||||
return fmt.Errorf("cannot set cgroups when they are disabled")
|
||||
|
||||
@@ -147,28 +147,26 @@ func (d *driver) Kill(p *execdriver.Command, sig int) error {
|
||||
|
||||
func (d *driver) Pause(c *execdriver.Command) error {
|
||||
active := d.activeContainers[c.ID]
|
||||
active.container.Cgroups.Freezer = "FROZEN"
|
||||
pid := c.Process.Pid
|
||||
|
||||
if systemd.UseSystemd() {
|
||||
_, err := systemd.Apply(active.container.Cgroups, pid)
|
||||
return err
|
||||
if active == nil {
|
||||
return fmt.Errorf("active container for %s does not exist", c.ID)
|
||||
}
|
||||
_, err := fs.Apply(active.container.Cgroups, pid)
|
||||
return err
|
||||
active.container.Cgroups.Freezer = "FROZEN"
|
||||
if systemd.UseSystemd() {
|
||||
return systemd.Freeze(active.container.Cgroups, active.container.Cgroups.Freezer)
|
||||
}
|
||||
return fs.Freeze(active.container.Cgroups, active.container.Cgroups.Freezer)
|
||||
}
|
||||
|
||||
func (d *driver) Unpause(c *execdriver.Command) error {
|
||||
active := d.activeContainers[c.ID]
|
||||
active.container.Cgroups.Freezer = "THAWED"
|
||||
pid := c.Process.Pid
|
||||
|
||||
if systemd.UseSystemd() {
|
||||
_, err := systemd.Apply(active.container.Cgroups, pid)
|
||||
return err
|
||||
if active == nil {
|
||||
return fmt.Errorf("active container for %s does not exist", c.ID)
|
||||
}
|
||||
_, err := fs.Apply(active.container.Cgroups, pid)
|
||||
return err
|
||||
active.container.Cgroups.Freezer = "THAWED"
|
||||
if systemd.UseSystemd() {
|
||||
return systemd.Freeze(active.container.Cgroups, active.container.Cgroups.Freezer)
|
||||
}
|
||||
return fs.Freeze(active.container.Cgroups, active.container.Cgroups.Freezer)
|
||||
}
|
||||
|
||||
func (d *driver) Terminate(p *execdriver.Command) error {
|
||||
|
||||
Reference in New Issue
Block a user