mirror of https://github.com/containers/podman.git
Merge pull request #211 from mheon/wireup_backends
Wire up API for CGroup Parent
This commit is contained in:
commit
6e8100cf2e
|
@ -82,7 +82,6 @@ type Container struct {
|
|||
// TODO Add readonly support
|
||||
// TODO add SHM size support
|
||||
// TODO add shared namespace support
|
||||
// TODO add cgroup parent support
|
||||
|
||||
// containerRuntimeInfo contains the current state of the container
|
||||
// It is stored on disk in a tmpfs and recreated on reboot
|
||||
|
@ -1247,7 +1246,7 @@ func (c *Container) cleanupStorage() error {
|
|||
|
||||
// CGroupPath returns a cgroups "path" for a given container.
|
||||
func (c *Container) CGroupPath() cgroups.Path {
|
||||
return cgroups.StaticPath(filepath.Join(CgroupParent, fmt.Sprintf("libpod-conmon-%s", c.ID())))
|
||||
return cgroups.StaticPath(filepath.Join(c.config.CgroupParent, fmt.Sprintf("libpod-conmon-%s", c.ID())))
|
||||
}
|
||||
|
||||
// copyHostFileToRundir copies the provided file to the runtimedir
|
||||
|
|
|
@ -25,7 +25,7 @@ func (c *Container) GetContainerPids() ([]string, error) {
|
|||
// Gets the pids for a container without locking. should only be called from a func where
|
||||
// locking has already been established.
|
||||
func (c *Container) getContainerPids() ([]string, error) {
|
||||
taskFile := filepath.Join("/sys/fs/cgroup/pids", CgroupParent, fmt.Sprintf("libpod-conmon-%s", c.ID()), c.ID(), "tasks")
|
||||
taskFile := filepath.Join("/sys/fs/cgroup/pids", c.config.CgroupParent, fmt.Sprintf("libpod-conmon-%s", c.ID()), c.ID(), "tasks")
|
||||
logrus.Debug("reading pids from ", taskFile)
|
||||
content, err := ioutil.ReadFile(taskFile)
|
||||
if err != nil {
|
||||
|
|
|
@ -477,6 +477,23 @@ func WithNetNS(portMappings []ocicni.PortMapping) CtrCreateOption {
|
|||
}
|
||||
}
|
||||
|
||||
// WithCgroupParent sets the Cgroup Parent of the new container
|
||||
func WithCgroupParent(parent string) CtrCreateOption {
|
||||
return func(ctr *Container) error {
|
||||
if ctr.valid {
|
||||
return ErrCtrFinalized
|
||||
}
|
||||
|
||||
if parent == "" {
|
||||
return errors.Wrapf(ErrInvalidArg, "cgroup parent cannot be empty")
|
||||
}
|
||||
|
||||
ctr.config.CgroupParent = parent
|
||||
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// Pod Creation Options
|
||||
|
||||
// WithPodName sets the name of the pod
|
||||
|
|
Loading…
Reference in New Issue