From d837fdf20465ffee55ff81efb3df8d010ecae765 Mon Sep 17 00:00:00 2001
From: zhongjiawei <zhongjiawei1@huawei.com>
Date: Mon, 17 Oct 2022 15:47:24 +0800
Subject: [PATCH] runc: print cgroup info if cpuset missing occurs

---
 runc-1.1.3/libcontainer/cgroups/fs/cpuset.go | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/runc-1.1.3/libcontainer/cgroups/fs/cpuset.go b/runc-1.1.3/libcontainer/cgroups/fs/cpuset.go
index 550baa4..341d5dc 100644
--- a/runc-1.1.3/libcontainer/cgroups/fs/cpuset.go
+++ b/runc-1.1.3/libcontainer/cgroups/fs/cpuset.go
@@ -172,6 +172,26 @@ func (s *CpusetGroup) ApplyDir(dir string, r *configs.Resources, pid int) error
 }
 
 func getCpusetSubsystemSettings(parent string) (cpus, mems string, err error) {
+	defer func() {
+		if err != nil {
+			minfo, err1 := ioutil.ReadFile("/proc/self/mountinfo")
+			if err1 != nil {
+				logrus.Errorf("Failed to read mountinfo when getSubsystemSettings get an error")
+			}
+
+			dirInfo := ""
+			fs, err2 := ioutil.ReadDir(parent)
+			if err2 != nil {
+				logrus.Errorf("Failed to read mountinfo when getSubsystemSettings get an error")
+			}
+			for _, f := range fs {
+				dirInfo = dirInfo + " " + f.Name()
+			}
+
+			logrus.Errorf("Read cpuset cgroup failed, print mountinfo and cgroup info here"+
+				"path: %s, mountinfo: [%s], dirinfo: [%s]", parent, string(minfo), dirInfo)
+		}
+	}()
 	if cpus, err = cgroups.ReadFile(parent, "cpuset.cpus"); err != nil {
 		return
 	}
-- 
2.30.0

