Browse code

UPSTREAM: google/cadvisor: <drop>: Hack around cgroup load

Running containerized on RHEL7 exposes a cAdvisor bug
https://github.com/google/cadvisor/issues/1461 where the cgroup path
given by docker (cpuacct,cpu) is used in preference to the cgroup path
mounted in with -v /sys:/sys. This commit skips all cgroup paths that
have a comma until we have a real fix in libcontainer and cadvisor.

Clayton Coleman authored on 2016/09/16 00:39:51
Showing 2 changed files
... ...
@@ -40,6 +40,10 @@ func FindCgroupMountpoint(subsystem string) (string, error) {
40 40
 		txt := scanner.Text()
41 41
 		fields := strings.Split(txt, " ")
42 42
 		for _, opt := range strings.Split(fields[len(fields)-1], ",") {
43
+			// temporary change to allow containerized cadvisor to start on RHEL (where host and container have reversed cpu,cpuacct)
44
+			if strings.Contains(fields[4], ",") {
45
+				continue
46
+			}
43 47
 			if opt == subsystem {
44 48
 				return fields[4], nil
45 49
 			}
... ...
@@ -67,6 +71,10 @@ func FindCgroupMountpointAndRoot(subsystem string) (string, string, error) {
67 67
 		txt := scanner.Text()
68 68
 		fields := strings.Split(txt, " ")
69 69
 		for _, opt := range strings.Split(fields[len(fields)-1], ",") {
70
+			// temporary change to allow containerized cadvisor to start on RHEL (where host and container have reversed cpu,cpuacct)
71
+			if strings.Contains(fields[4], ",") {
72
+				continue
73
+			}
70 74
 			if opt == subsystem {
71 75
 				return fields[4], fields[3], nil
72 76
 			}
... ...
@@ -99,6 +107,12 @@ func FindCgroupMountpointDir() (string, error) {
99 99
 	for scanner.Scan() {
100 100
 		text := scanner.Text()
101 101
 		fields := strings.Split(text, " ")
102
+
103
+		// temporary change to allow containerized cadvisor to start on RHEL (where host and container have reversed cpu,cpuacct)
104
+		if strings.Contains(fields[4], ",") {
105
+			continue
106
+		}
107
+
102 108
 		// Safe as mountinfo encodes mountpoints with spaces as \040.
103 109
 		index := strings.Index(text, " - ")
104 110
 		postSeparatorFields := strings.Fields(text[index+3:])
... ...
@@ -153,6 +167,10 @@ func getCgroupMountsHelper(ss map[string]bool, mi io.Reader) ([]Mount, error) {
153 153
 			continue
154 154
 		}
155 155
 		fields := strings.Split(txt, " ")
156
+		// temporary change to allow containerized cadvisor to start on RHEL (where host and container have reversed cpu,cpuacct)
157
+		if strings.Contains(fields[4], ",") {
158
+			continue
159
+		}
156 160
 		m := Mount{
157 161
 			Mountpoint: fields[4],
158 162
 			Root:       fields[3],
... ...
@@ -609,12 +609,12 @@ func (r *resourceCollector) collectStats(oldStatsMap map[string]*stats.Container
609 609
 	defer r.lock.Unlock()
610 610
 	for _, name := range r.containers {
611 611
 		cStats, ok := cStatsMap[name]
612
-		if !ok {
612
+		if !ok || cStats.CPU == nil {
613 613
 			Logf("Missing info/stats for container %q on node %q", name, r.node)
614 614
 			return
615 615
 		}
616 616
 
617
-		if oldStats, ok := oldStatsMap[name]; ok {
617
+		if oldStats, ok := oldStatsMap[name]; ok && oldStats.CPU != nil {
618 618
 			if oldStats.CPU.Time.Equal(cStats.CPU.Time) {
619 619
 				// No change -> skip this stat.
620 620
 				continue