[ARVADOS] updated: 1.1.3-71-ga837c67

Git user git at public.curoverse.com
Mon Feb 26 09:49:08 EST 2018


Summary of changes:
 services/crunch-dispatch-slurm/squeue.go      |  18 +++--
 services/crunch-dispatch-slurm/squeue_test.go | 110 ++++++++++++++++++++++++++
 2 files changed, 121 insertions(+), 7 deletions(-)
 create mode 100644 services/crunch-dispatch-slurm/squeue_test.go

       via  a837c67de6903827f7dfb3b19adfc82c30a87861 (commit)
       via  fce5b69e1504c3421705292c823084f6637d6c11 (commit)
      from  498d29adee40f671fd2924c410226db7a6a0ba93 (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 a837c67de6903827f7dfb3b19adfc82c30a87861
Author: Tom Clegg <tclegg at veritasgenetics.com>
Date:   Mon Feb 26 09:46:39 2018 -0500

    12552: Skip extra lookup.
    
    Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tclegg at veritasgenetics.com>

diff --git a/services/crunch-dispatch-slurm/squeue.go b/services/crunch-dispatch-slurm/squeue.go
index e269954..b8e3108 100644
--- a/services/crunch-dispatch-slurm/squeue.go
+++ b/services/crunch-dispatch-slurm/squeue.go
@@ -54,15 +54,16 @@ func (sqc *SqueueChecker) SetPriority(uuid string, want int64) {
 	sqc.startOnce.Do(sqc.start)
 	sqc.L.Lock()
 	defer sqc.L.Unlock()
-	if _, ok := sqc.queue[uuid]; !ok {
+	job, ok := sqc.queue[uuid]
+	if !ok {
 		// Wait in case the slurm job was just submitted and
 		// will appear in the next squeue update.
 		sqc.Wait()
-		if _, ok = sqc.queue[uuid]; !ok {
+		if job, ok = sqc.queue[uuid]; !ok {
 			return
 		}
 	}
-	sqc.queue[uuid].wantPriority = want
+	job.wantPriority = want
 }
 
 // adjust slurm job nice values as needed to ensure slurm priority

commit fce5b69e1504c3421705292c823084f6637d6c11
Author: Tom Clegg <tclegg at veritasgenetics.com>
Date:   Mon Feb 26 09:46:31 2018 -0500

    12552: Add slurm-renice test cases.
    
    Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tclegg at veritasgenetics.com>

diff --git a/services/crunch-dispatch-slurm/squeue.go b/services/crunch-dispatch-slurm/squeue.go
index d15489b..e269954 100644
--- a/services/crunch-dispatch-slurm/squeue.go
+++ b/services/crunch-dispatch-slurm/squeue.go
@@ -51,6 +51,7 @@ func (sqc *SqueueChecker) HasUUID(uuid string) bool {
 // SetPriority sets or updates the desired (Arvados) priority for a
 // container.
 func (sqc *SqueueChecker) SetPriority(uuid string, want int64) {
+	sqc.startOnce.Do(sqc.start)
 	sqc.L.Lock()
 	defer sqc.L.Unlock()
 	if _, ok := sqc.queue[uuid]; !ok {
@@ -132,11 +133,13 @@ func (sqc *SqueueChecker) check() {
 			log.Printf("warning: ignoring unparsed line in squeue output: %q", line)
 			continue
 		}
-		newq[uuid] = &slurmJob{
-			uuid:     uuid,
-			priority: p,
-			nice:     n,
+		replacing, ok := sqc.queue[uuid]
+		if !ok {
+			replacing = &slurmJob{uuid: uuid}
 		}
+		replacing.priority = p
+		replacing.nice = n
+		newq[uuid] = replacing
 	}
 	sqc.queue = newq
 	sqc.Broadcast()
diff --git a/services/crunch-dispatch-slurm/squeue_test.go b/services/crunch-dispatch-slurm/squeue_test.go
new file mode 100644
index 0000000..4df469b
--- /dev/null
+++ b/services/crunch-dispatch-slurm/squeue_test.go
@@ -0,0 +1,110 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+package main
+
+import (
+	"time"
+
+	. "gopkg.in/check.v1"
+)
+
+var _ = Suite(&SqueueSuite{})
+
+type SqueueSuite struct{}
+
+func (s *SqueueSuite) TestReniceAll(c *C) {
+	uuids := []string{"zzzzz-dz642-fake0fake0fake0", "zzzzz-dz642-fake1fake1fake1", "zzzzz-dz642-fake2fake2fake2"}
+	for _, test := range []struct {
+		spread int64
+		squeue string
+		want   map[string]int64
+		expect [][]string
+	}{
+		{
+			spread: 0,
+			squeue: uuids[0] + " 10000 4294000000\n",
+			want:   map[string]int64{uuids[0]: 1},
+			expect: [][]string{{uuids[0], "0"}},
+		},
+		{ // fake0 priority is too high
+			spread: 0,
+			squeue: uuids[0] + " 10000 4294000777\n" + uuids[1] + " 10000 4294000444\n",
+			want:   map[string]int64{uuids[0]: 1, uuids[1]: 999},
+			expect: [][]string{{uuids[1], "0"}, {uuids[0], "334"}},
+		},
+		{ // non-zero spread
+			spread: 100,
+			squeue: uuids[0] + " 10000 4294000777\n" + uuids[1] + " 10000 4294000444\n",
+			want:   map[string]int64{uuids[0]: 1, uuids[1]: 999},
+			expect: [][]string{{uuids[1], "0"}, {uuids[0], "434"}},
+		},
+		{ // ignore fake2 because SetPriority() not called
+			squeue: uuids[0] + " 10000 4294000000\n" + uuids[1] + " 10000 4294000111\n" + uuids[2] + " 10000 4294000222\n",
+			want:   map[string]int64{uuids[0]: 999, uuids[1]: 1},
+			expect: [][]string{{uuids[0], "0"}, {uuids[1], "112"}},
+		},
+	} {
+		c.Logf("spread=%d squeue=%q want=%v -> expect=%v", test.spread, test.squeue, test.want, test.expect)
+		slurm := &slurmFake{
+			queue: test.squeue,
+		}
+		sqc := &SqueueChecker{
+			Slurm:          slurm,
+			PrioritySpread: test.spread,
+			Period:         time.Hour,
+		}
+		sqc.startOnce.Do(sqc.start)
+		sqc.check()
+		for uuid, pri := range test.want {
+			sqc.SetPriority(uuid, pri)
+		}
+		sqc.reniceAll()
+		c.Check(slurm.didRenice, DeepEquals, test.expect)
+		sqc.Stop()
+	}
+}
+
+// If the given UUID isn't in the slurm queue yet, SetPriority()
+// should wait for it to appear on the very next poll, then give up.
+func (s *SqueueSuite) TestSetPriorityBeforeQueued(c *C) {
+	uuidGood := "zzzzz-dz642-fake0fake0fake0"
+	uuidBad := "zzzzz-dz642-fake1fake1fake1"
+
+	slurm := &slurmFake{}
+	sqc := &SqueueChecker{
+		Slurm:  slurm,
+		Period: time.Hour,
+	}
+	sqc.startOnce.Do(sqc.start)
+	sqc.Stop()
+	sqc.check()
+
+	done := make(chan struct{})
+	go func() {
+		sqc.SetPriority(uuidGood, 123)
+		sqc.SetPriority(uuidBad, 345)
+		close(done)
+	}()
+	c.Check(sqc.queue[uuidGood], IsNil)
+	c.Check(sqc.queue[uuidBad], IsNil)
+	timeout := time.NewTimer(time.Second)
+	defer timeout.Stop()
+	tick := time.NewTicker(time.Millisecond)
+	defer tick.Stop()
+	for {
+		select {
+		case <-tick.C:
+			slurm.queue = uuidGood + " 0 12345\n"
+			sqc.check()
+		case <-timeout.C:
+			c.Fatal("timed out")
+		case <-done:
+			c.Assert(sqc.queue[uuidGood], NotNil)
+			c.Check(sqc.queue[uuidGood].wantPriority, Equals, int64(123))
+			c.Check(sqc.queue[uuidBad], IsNil)
+			return
+		}
+	}
+}

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list