68 lines
2.4 KiB
Diff
68 lines
2.4 KiB
Diff
|
|
From 2150d9c48ff9073b0d85e4075b508579d82f3d27 Mon Sep 17 00:00:00 2001
|
||
|
|
From: zhangtianyang <zhangtianyang2@huawei.com>
|
||
|
|
Date: Fri, 18 Oct 2019 19:59:21 +0800
|
||
|
|
Subject: [PATCH] runc: add log message for cgroup file check
|
||
|
|
|
||
|
|
reason:docker report "no such file" when try to write cpuset.mems,
|
||
|
|
not sure weather is deleted or not generated by kernel. so add
|
||
|
|
cgroup file check messages for further maintainance.
|
||
|
|
|
||
|
|
Change-Id: I4c835f62547b0404a9cffeda643fe028f1b4aa0f
|
||
|
|
Signed-off-by: zhangtianyang <zhangtianyang2@huawei.com>
|
||
|
|
---
|
||
|
|
libcontainer/cgroups/fs/apply_raw.go | 7 ++++++-
|
||
|
|
libcontainer/cgroups/fs/cpuset.go | 13 +++++++++++--
|
||
|
|
2 files changed, 17 insertions(+), 3 deletions(-)
|
||
|
|
|
||
|
|
diff --git a/libcontainer/cgroups/fs/apply_raw.go b/libcontainer/cgroups/fs/apply_raw.go
|
||
|
|
index 1bf59a47..7677f336 100644
|
||
|
|
--- a/libcontainer/cgroups/fs/apply_raw.go
|
||
|
|
+++ b/libcontainer/cgroups/fs/apply_raw.go
|
||
|
|
@@ -313,7 +313,12 @@ func writeFile(dir, file, data string) error {
|
||
|
|
return fmt.Errorf("no such directory for %s", file)
|
||
|
|
}
|
||
|
|
if err := ioutil.WriteFile(filepath.Join(dir, file), []byte(data), 0700); err != nil {
|
||
|
|
- return fmt.Errorf("failed to write %v to %v: %v", data, file, err)
|
||
|
|
+ ret := fmt.Errorf("failed to write %v to %v: %v", data, file, err)
|
||
|
|
+ if _, err = os.Stat(dir); err != nil {
|
||
|
|
+ ret = fmt.Errorf("%v, failed to stat %v, %v", ret, dir, err)
|
||
|
|
+ }
|
||
|
|
+
|
||
|
|
+ return ret
|
||
|
|
}
|
||
|
|
return nil
|
||
|
|
}
|
||
|
|
diff --git a/libcontainer/cgroups/fs/cpuset.go b/libcontainer/cgroups/fs/cpuset.go
|
||
|
|
index 069c4915..bc654948 100644
|
||
|
|
--- a/libcontainer/cgroups/fs/cpuset.go
|
||
|
|
+++ b/libcontainer/cgroups/fs/cpuset.go
|
||
|
|
@@ -31,14 +31,23 @@ func (s *CpusetGroup) Apply(d *cgroupData) error {
|
||
|
|
}
|
||
|
|
|
||
|
|
func (s *CpusetGroup) Set(path string, cgroup *configs.Cgroup) error {
|
||
|
|
+ var ret error
|
||
|
|
if cgroup.Resources.CpusetCpus != "" {
|
||
|
|
if err := writeFile(path, "cpuset.cpus", cgroup.Resources.CpusetCpus); err != nil {
|
||
|
|
- return err
|
||
|
|
+ ret = fmt.Errorf("failed to set cpuset.cpus, %v", err)
|
||
|
|
+ if _, err := os.Stat(path); err != nil {
|
||
|
|
+ ret = fmt.Errorf("%v, failed to stat %v, %v", ret, path, err)
|
||
|
|
+ }
|
||
|
|
+ return ret
|
||
|
|
}
|
||
|
|
}
|
||
|
|
if cgroup.Resources.CpusetMems != "" {
|
||
|
|
if err := writeFile(path, "cpuset.mems", cgroup.Resources.CpusetMems); err != nil {
|
||
|
|
- return err
|
||
|
|
+ ret = fmt.Errorf("failed to set cpuset.cpus, %v", err)
|
||
|
|
+ if _, err := os.Stat(path); err != nil {
|
||
|
|
+ ret = fmt.Errorf("%v, failed to stat %v, %v", ret, path, err)
|
||
|
|
+ }
|
||
|
|
+ return ret
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return nil
|
||
|
|
--
|
||
|
|
2.19.1
|
||
|
|
|