diff options
author | Jacob Vosmaer <jacob@gitlab.com> | 2017-12-12 19:51:01 +0300 |
---|---|---|
committer | Jacob Vosmaer <jacob@gitlab.com> | 2017-12-15 15:09:25 +0300 |
commit | 80606c4a97b1619df10df8da9e7f30bce12039c5 (patch) | |
tree | eaaed246c4ec2349347c77f95bbd4acb418cf0b4 | |
parent | ced5ca6eb8654662045f84cef17d66ff68006b8f (diff) |
Fix broken Ruby test setup in CI
-rw-r--r-- | internal/supervisor/monitor.go | 8 | ||||
-rw-r--r-- | internal/supervisor/supervisor.go | 4 | ||||
-rw-r--r-- | internal/testhelper/testhelper.go | 13 |
3 files changed, 13 insertions, 12 deletions
diff --git a/internal/supervisor/monitor.go b/internal/supervisor/monitor.go index 447f906bd..c87193a8d 100644 --- a/internal/supervisor/monitor.go +++ b/internal/supervisor/monitor.go @@ -7,6 +7,7 @@ import ( "time" "github.com/prometheus/client_golang/prometheus" + log "github.com/sirupsen/logrus" ) var ( @@ -24,12 +25,13 @@ func init() { } type monitorProcess struct { - name string pid int wait <-chan struct{} } -func monitorRss(procs <-chan monitorProcess, done chan<- struct{}, events chan<- Event, threshold int) { +func monitorRss(procs <-chan monitorProcess, done chan<- struct{}, events chan<- Event, name string, threshold int) { + log.WithField("supervisor.name", name).WithField("supervisor.rss_threshold", threshold).Info("starting RSS monitor") + t := time.NewTicker(15 * time.Second) defer t.Stop() @@ -39,7 +41,7 @@ func monitorRss(procs <-chan monitorProcess, done chan<- struct{}, events chan<- monitorLoop: for { rss := 1024 * getRss(mp.pid) - rssGauge.WithLabelValues(mp.name).Set(float64(rss)) + rssGauge.WithLabelValues(name).Set(float64(rss)) if rss > 0 { event := Event{Type: MemoryLow, Pid: mp.pid} diff --git a/internal/supervisor/supervisor.go b/internal/supervisor/supervisor.go index c862ec723..eba248549 100644 --- a/internal/supervisor/supervisor.go +++ b/internal/supervisor/supervisor.go @@ -106,7 +106,7 @@ func watch(p *Process) { // on the monitor goroutine. monitorChan := make(chan monitorProcess, config.CrashThreshold) monitorDone := make(chan struct{}) - go monitorRss(monitorChan, monitorDone, p.events, p.memoryThreshold) + go monitorRss(monitorChan, monitorDone, p.events, p.Name, p.memoryThreshold) spawnLoop: for { @@ -144,7 +144,7 @@ spawnLoop: logger.WithError(err).Warn("exited") }(cmd, waitCh) - monitorChan <- monitorProcess{name: p.Name, pid: pid, wait: waitCh} + monitorChan <- monitorProcess{pid: pid, wait: waitCh} waitLoop: for { diff --git a/internal/testhelper/testhelper.go b/internal/testhelper/testhelper.go index 62dc44cd1..eed910f1e 100644 --- a/internal/testhelper/testhelper.go +++ b/internal/testhelper/testhelper.go @@ -245,14 +245,13 @@ func ConfigureRuby() { if dir := os.Getenv("GITALY_TEST_RUBY_DIR"); len(dir) > 0 { // Sometimes runtime.Caller is unreliable. This environment variable provides a bypass. config.Config.Ruby.Dir = dir - return - } - - _, currentFile, _, ok := runtime.Caller(0) - if !ok { - log.Fatal("Could not get caller info") + } else { + _, currentFile, _, ok := runtime.Caller(0) + if !ok { + log.Fatal("Could not get caller info") + } + config.Config.Ruby.Dir = path.Join(path.Dir(currentFile), "../../ruby") } - config.Config.Ruby.Dir = path.Join(path.Dir(currentFile), "../../ruby") if err := config.ConfigureRuby(); err != nil { log.Fatal("validate ruby config: %v", err) |