[ARVADOS] updated: cf1f493d2d782ff7481e74d7163f02ac2948d89f
Git user
git at public.curoverse.com
Mon Jul 4 17:08:47 EDT 2016
Summary of changes:
lib/crunchstat/crunchstat.go | 29 ++++++++++++++++++-----------
lib/crunchstat/crunchstat_test.go | 3 +++
services/crunch-run/crunchrun.go | 4 ++--
3 files changed, 23 insertions(+), 13 deletions(-)
via cf1f493d2d782ff7481e74d7163f02ac2948d89f (commit)
via c63c699aa9948f6a672536ba08e664471fb0d654 (commit)
via 63365dbaacaa3729ad21a016b97eef4d36a86536 (commit)
from c9e64770f294108a4f1c82bd892d740573e21a50 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit cf1f493d2d782ff7481e74d7163f02ac2948d89f
Author: Tom Clegg <tom at curoverse.com>
Date: Mon Jul 4 17:08:37 2016 -0400
8016: Clarify comments/docs and cpuSample initialization.
diff --git a/lib/crunchstat/crunchstat.go b/lib/crunchstat/crunchstat.go
index e0ef058..03cfa7d 100644
--- a/lib/crunchstat/crunchstat.go
+++ b/lib/crunchstat/crunchstat.go
@@ -40,7 +40,7 @@ type Reporter struct {
// Where cgroup accounting files live on this system, e.g.,
// "/sys/fs/cgroup".
- CgroupRoot string
+ CgroupRoot string
// Parent cgroup, e.g., "docker".
CgroupParent string
@@ -312,6 +312,9 @@ func (r *Reporter) getCPUCount() int64 {
}
defer cpusetFile.Close()
b, err := r.readAllOrWarn(cpusetFile)
+ if err != nil {
+ return 0
+ }
sp := strings.Split(string(b), ",")
cpus := int64(0)
for _, v := range sp {
@@ -337,12 +340,16 @@ func (r *Reporter) doCPUStats() {
return
}
- nextSample := cpuSample{true, time.Now(), 0, 0, r.getCPUCount()}
var userTicks, sysTicks int64
fmt.Sscanf(string(b), "user %d\nsystem %d", &userTicks, &sysTicks)
userHz := float64(C.sysconf(C._SC_CLK_TCK))
- nextSample.user = float64(userTicks) / userHz
- nextSample.sys = float64(sysTicks) / userHz
+ nextSample := cpuSample{
+ hasData: true,
+ sampleTime: time.Now(),
+ user: float64(userTicks) / userHz,
+ sys: float64(sysTicks) / userHz,
+ cpus: r.getCPUCount(),
+ }
delta := ""
if r.lastCPUSample.hasData {
@@ -356,8 +363,8 @@ func (r *Reporter) doCPUStats() {
r.lastCPUSample = nextSample
}
-// Report stats periodically until r.done indicates someone called
-// Stop.
+// Report stats periodically until we learn (via r.done) that someone
+// called Stop.
func (r *Reporter) run() {
r.reportedStatFile = make(map[string]string)
@@ -383,7 +390,7 @@ func (r *Reporter) run() {
}
// If CID is empty, wait for it to appear in CIDFile. Return true if
-// we get it before r.done indicates someone called Stop.
+// we get it before we learn (via r.done) that someone called Stop.
func (r *Reporter) waitForCIDFile() bool {
if r.CID != "" || r.CIDFile == "" {
return true
diff --git a/services/crunch-run/crunchrun.go b/services/crunch-run/crunchrun.go
index 9a508d5..2795cb0 100644
--- a/services/crunch-run/crunchrun.go
+++ b/services/crunch-run/crunchrun.go
@@ -821,7 +821,7 @@ func NewContainerRunner(api IArvadosClient,
}
func main() {
- statInterval := flag.Duration("crunchstat-interval", 10*time.Second, "resource usage statistics reporting period")
+ statInterval := flag.Duration("crunchstat-interval", 10*time.Second, "sampling period for periodic resource usage reporting")
cgroupRoot := flag.String("cgroup-root", "/sys/fs/cgroup", "path to sysfs cgroup tree")
cgroupParent := flag.String("cgroup-parent", "docker", "name of container's parent cgroup")
flag.Parse()
commit c63c699aa9948f6a672536ba08e664471fb0d654
Author: Tom Clegg <tom at curoverse.com>
Date: Mon Jul 4 17:07:54 2016 -0400
8016: Rename Poll to PollPeriod.
diff --git a/lib/crunchstat/crunchstat.go b/lib/crunchstat/crunchstat.go
index 0a6d3bc..e0ef058 100644
--- a/lib/crunchstat/crunchstat.go
+++ b/lib/crunchstat/crunchstat.go
@@ -46,7 +46,7 @@ type Reporter struct {
CgroupParent string
// Interval between samples. Must be positive.
- Poll time.Duration
+ PollPeriod time.Duration
// Where to write statistics. Must not be nil.
Logger *log.Logger
@@ -368,7 +368,7 @@ func (r *Reporter) run() {
r.lastNetSample = make(map[string]ioSample)
r.lastDiskSample = make(map[string]ioSample)
- ticker := time.NewTicker(r.Poll)
+ ticker := time.NewTicker(r.PollPeriod)
for {
r.doMemoryStats()
r.doCPUStats()
@@ -413,7 +413,7 @@ func (r *Reporter) waitForCIDFile() bool {
func (r *Reporter) waitForCgroup() bool {
ticker := time.NewTicker(100 * time.Millisecond)
defer ticker.Stop()
- warningTimer := time.After(r.Poll)
+ warningTimer := time.After(r.PollPeriod)
for {
c, err := r.openStatFile("cpuacct", "cgroup.procs", false)
if err == nil {
@@ -423,7 +423,7 @@ func (r *Reporter) waitForCgroup() bool {
select {
case <-ticker.C:
case <-warningTimer:
- r.Logger.Printf("cgroup stats files have not appeared after %v (config error?) -- still waiting...", r.Poll)
+ r.Logger.Printf("cgroup stats files have not appeared after %v (config error?) -- still waiting...", r.PollPeriod)
case <-r.done:
r.Logger.Printf("cgroup stats files never appeared for %v", r.CID)
return false
diff --git a/services/crunch-run/crunchrun.go b/services/crunch-run/crunchrun.go
index b064c42..9a508d5 100644
--- a/services/crunch-run/crunchrun.go
+++ b/services/crunch-run/crunchrun.go
@@ -395,7 +395,7 @@ func (runner *ContainerRunner) StartCrunchstat() {
Logger: log.New(runner.statLogger, "", 0),
CgroupParent: runner.cgroupParent,
CgroupRoot: runner.cgroupRoot,
- Poll: runner.statInterval,
+ PollPeriod: runner.statInterval,
}
runner.statReporter.Start()
}
commit 63365dbaacaa3729ad21a016b97eef4d36a86536
Author: Tom Clegg <tom at curoverse.com>
Date: Mon Jul 4 17:06:48 2016 -0400
8016: Fix race in test case.
diff --git a/lib/crunchstat/crunchstat_test.go b/lib/crunchstat/crunchstat_test.go
index 864a3e3..697f235 100644
--- a/lib/crunchstat/crunchstat_test.go
+++ b/lib/crunchstat/crunchstat_test.go
@@ -19,10 +19,12 @@ func TestReadAllOrWarnFail(t *testing.T) {
logger, rcv := bufLogger()
rep := Reporter{Logger: logger}
+ done := make(chan bool)
var msg []byte
var err error
go func() {
msg, err = rcv.ReadBytes('\n')
+ close(done)
}()
{
// The special file /proc/self/mem can be opened for
@@ -35,6 +37,7 @@ func TestReadAllOrWarnFail(t *testing.T) {
t.Fatalf("Expected error, got %v", x)
}
}
+ <-done
if err != nil {
t.Fatal(err)
} else if matched, err := regexp.MatchString("^read /proc/self/mem: .*", string(msg)); err != nil || !matched {
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list