17244: Use crunch-run's cgroup, not init's, for "host" stats.
[arvados.git] / lib / crunchrun / crunchrun.go
index 1c0cf621dbf730e409193efc7cbe44a0e90daa8e..9add35335f39380ca61f78390f0eae1ce7ebda03 100644 (file)
@@ -742,8 +742,16 @@ func (runner *ContainerRunner) startHoststat() error {
        }
        runner.hoststatLogger = NewThrottledLogger(w)
        runner.hoststatReporter = &crunchstat.Reporter{
-               Logger:     log.New(runner.hoststatLogger, "", 0),
-               Pid:        func() int { return 1 },
+               Logger: log.New(runner.hoststatLogger, "", 0),
+               // Our own cgroup is the "host" cgroup, in the sense
+               // that it accounts for resource usage outside the
+               // container. It doesn't count _all_ resource usage on
+               // the system.
+               //
+               // TODO?: Use the furthest ancestor of our own cgroup
+               // that has stats available. (Currently crunchstat
+               // does not have that capability.)
+               Pid:        os.Getpid,
                PollPeriod: runner.statInterval,
        }
        runner.hoststatReporter.Start()