mirror of
https://github.com/opencontainers/runc.git
synced 2025-10-05 07:27:03 +08:00
Add cgroup manage for mocking of package resources
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:

committed by
Victor Marmol

parent
926ab56ea8
commit
ccb83a1e83
@@ -2,17 +2,14 @@
|
||||
|
||||
package libcontainer
|
||||
|
||||
import (
|
||||
"github.com/docker/libcontainer/cgroups/fs"
|
||||
"github.com/docker/libcontainer/cgroups/systemd"
|
||||
"github.com/docker/libcontainer/network"
|
||||
)
|
||||
import "github.com/docker/libcontainer/network"
|
||||
|
||||
type linuxContainer struct {
|
||||
id string
|
||||
root string
|
||||
config *Config
|
||||
state *State
|
||||
id string
|
||||
root string
|
||||
config *Config
|
||||
state *State
|
||||
cgroupManager CgroupManager
|
||||
}
|
||||
|
||||
func (c *linuxContainer) ID() string {
|
||||
@@ -23,21 +20,12 @@ func (c *linuxContainer) Config() *Config {
|
||||
return c.config
|
||||
}
|
||||
|
||||
func (c *linuxContainer) RunState() (*RunState, error) {
|
||||
func (c *linuxContainer) RunState() (RunState, error) {
|
||||
panic("not implemented")
|
||||
}
|
||||
|
||||
func (c *linuxContainer) Processes() ([]int, error) {
|
||||
var (
|
||||
err error
|
||||
pids []int
|
||||
)
|
||||
|
||||
if systemd.UseSystemd() {
|
||||
pids, err = systemd.GetPids(c.config.Cgroups)
|
||||
} else {
|
||||
pids, err = fs.GetPids(c.config.Cgroups)
|
||||
}
|
||||
pids, err := c.cgroupManager.GetPids(c.config.Cgroups)
|
||||
if err != nil {
|
||||
return nil, newGenericError(err, SystemError)
|
||||
}
|
||||
@@ -50,15 +38,9 @@ func (c *linuxContainer) Stats() (*ContainerStats, error) {
|
||||
stats = &ContainerStats{}
|
||||
)
|
||||
|
||||
if systemd.UseSystemd() {
|
||||
stats.CgroupStats, err = systemd.GetStats(c.config.Cgroups)
|
||||
} else {
|
||||
stats.CgroupStats, err = fs.GetStats(c.config.Cgroups)
|
||||
}
|
||||
if err != nil {
|
||||
if stats.CgroupStats, err = c.cgroupManager.GetStats(c.config.Cgroups); err != nil {
|
||||
return stats, newGenericError(err, SystemError)
|
||||
}
|
||||
|
||||
if stats.NetworkStats, err = network.GetStats(&c.state.NetworkState); err != nil {
|
||||
return stats, newGenericError(err, SystemError)
|
||||
}
|
||||
|
Reference in New Issue
Block a user