debugging
Signed-off-by: Jess Frazelle <jess@mesosphere.com>
This commit is contained in:
parent
8ddaf7168e
commit
06044a8174
8 changed files with 51 additions and 14 deletions
17
vendor/github.com/opencontainers/runc/libcontainer/cgroups/fs/apply_raw.go
generated
vendored
17
vendor/github.com/opencontainers/runc/libcontainer/cgroups/fs/apply_raw.go
generated
vendored
|
@ -111,11 +111,14 @@ func (m *Manager) Apply(pid int) (err error) {
|
|||
|
||||
var c = m.Cgroups
|
||||
|
||||
logrus.Debugf("pre get cgroups data: %#v", c)
|
||||
d, err := getCgroupData(m.Cgroups, pid)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
logrus.Debugf("cgroups data: %#v, config: %#v", d, d.config)
|
||||
|
||||
if c.Paths != nil {
|
||||
paths := make(map[string]string)
|
||||
for name, path := range c.Paths {
|
||||
|
@ -129,6 +132,7 @@ func (m *Manager) Apply(pid int) (err error) {
|
|||
paths[name] = path
|
||||
}
|
||||
m.Paths = paths
|
||||
logrus.Debugf("cgroups apply paths: %#v", m.Paths)
|
||||
return cgroups.EnterPid(m.Paths, pid)
|
||||
}
|
||||
|
||||
|
@ -136,6 +140,7 @@ func (m *Manager) Apply(pid int) (err error) {
|
|||
defer m.mu.Unlock()
|
||||
paths := make(map[string]string)
|
||||
for _, sys := range subsystems {
|
||||
logrus.Debugf("applying cgroups to subsystem %#v", sys)
|
||||
if err := sys.Apply(d); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -353,23 +358,25 @@ func writeFile(dir, file, data string) error {
|
|||
if dir == "" {
|
||||
return fmt.Errorf("no such directory for %s", file)
|
||||
}
|
||||
|
||||
// get the current user
|
||||
u, err := user.CurrentUser()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := os.Chown(dir, u.Uid, u.Gid); err != nil {
|
||||
return fmt.Errorf("failed to chown %s to %d:%d -> %v", dir, u.Uid, u.Gid, err)
|
||||
if err := os.Lchown(dir, u.Uid, u.Gid); err != nil {
|
||||
return fmt.Errorf("failed to chown to %d:%d -> %v", u.Uid, u.Gid, err)
|
||||
}
|
||||
logrus.Debugf("chown dir %s to %d:%d", dir, u.Uid, u.Gid)
|
||||
|
||||
if err := os.Chown(filepath.Join(dir, "tasks"), u.Uid, u.Gid); err != nil {
|
||||
return fmt.Errorf("failed to chown %s/tasks to %d:%d -> %v", dir, u.Uid, u.Gid, err)
|
||||
if err := os.Lchown(filepath.Join(dir, file), u.Uid, u.Gid); err != nil {
|
||||
return fmt.Errorf("failed to chown to %d:%d -> %v", u.Uid, u.Gid, err)
|
||||
}
|
||||
logrus.Debugf("chown %s to %d:%d", filepath.Join(dir, file), u.Uid, u.Gid)
|
||||
|
||||
if err := ioutil.WriteFile(filepath.Join(dir, file), []byte(data), 0700); err != nil {
|
||||
logrus.Debugf("failed to write %v to %v: %v", data, file, err)
|
||||
//return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
2
vendor/github.com/opencontainers/runc/libcontainer/cgroups/fs/cpuset.go
generated
vendored
2
vendor/github.com/opencontainers/runc/libcontainer/cgroups/fs/cpuset.go
generated
vendored
|
@ -10,6 +10,7 @@ import (
|
|||
"path/filepath"
|
||||
"strconv"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/opencontainers/runc/libcontainer/cgroups"
|
||||
"github.com/opencontainers/runc/libcontainer/configs"
|
||||
libcontainerUtils "github.com/opencontainers/runc/libcontainer/utils"
|
||||
|
@ -27,6 +28,7 @@ func (s *CpusetGroup) Apply(d *cgroupData) error {
|
|||
if err != nil && !cgroups.IsNotFound(err) {
|
||||
return err
|
||||
}
|
||||
logrus.Debugf("apply cpuset dir is %s", dir)
|
||||
return s.ApplyDir(dir, d.config, d.pid)
|
||||
}
|
||||
|
||||
|
|
2
vendor/github.com/opencontainers/runc/libcontainer/container_linux.go
generated
vendored
2
vendor/github.com/opencontainers/runc/libcontainer/container_linux.go
generated
vendored
|
@ -171,6 +171,7 @@ func (c *linuxContainer) Set(config configs.Config) error {
|
|||
c.m.Lock()
|
||||
defer c.m.Unlock()
|
||||
c.config = &config
|
||||
logrus.Debugf("setting cgroups")
|
||||
return c.cgroupManager.Set(c.config)
|
||||
}
|
||||
|
||||
|
@ -741,6 +742,7 @@ func (c *linuxContainer) Restore(process *Process, criuOpts *CriuOpts) error {
|
|||
}
|
||||
|
||||
func (c *linuxContainer) criuApplyCgroups(pid int, req *criurpc.CriuReq) error {
|
||||
logrus.Debugf("criu apply cgroups")
|
||||
if err := c.cgroupManager.Apply(pid); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
4
vendor/github.com/opencontainers/runc/libcontainer/process_linux.go
generated
vendored
4
vendor/github.com/opencontainers/runc/libcontainer/process_linux.go
generated
vendored
|
@ -13,6 +13,7 @@ import (
|
|||
"strconv"
|
||||
"syscall"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/opencontainers/runc/libcontainer/cgroups"
|
||||
"github.com/opencontainers/runc/libcontainer/configs"
|
||||
"github.com/opencontainers/runc/libcontainer/system"
|
||||
|
@ -247,6 +248,9 @@ func (p *initProcess) start() error {
|
|||
return newSystemError(err)
|
||||
}
|
||||
p.setExternalDescriptors(fds)
|
||||
|
||||
logrus.Debugf("starting process apply cgroups")
|
||||
|
||||
// Do this before syncing with child so that no children
|
||||
// can escape the cgroup
|
||||
if err := p.manager.Apply(p.pid()); err != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue