[ARVADOS] created: 83c8f1685d812c31d8bd568f3c2ac1edcd120aed

Git user git at public.curoverse.com
Tue Feb 14 16:27:32 EST 2017


        at  83c8f1685d812c31d8bd568f3c2ac1edcd120aed (commit)


commit 83c8f1685d812c31d8bd568f3c2ac1edcd120aed
Author: radhika <radhika at curoverse.com>
Date:   Tue Feb 14 16:26:39 2017 -0500

    10979: trackContainers func in crunch-dispatch-slurm.go

diff --git a/sdk/go/dispatch/dispatch.go b/sdk/go/dispatch/dispatch.go
index 5d85c1b..e489ac7 100644
--- a/sdk/go/dispatch/dispatch.go
+++ b/sdk/go/dispatch/dispatch.go
@@ -225,3 +225,8 @@ func (tracker *runTracker) update(c arvados.Container) {
 	}
 	tracker.updates <- c
 }
+
+// Start a tracker for the given uuid if one is not already existing, despite its state.
+// its vs. it's -- episode 5 from Series 1 of Netflix' "A Series of Unfortunate Events"
+func (dispatcher *Dispatcher) TrackContainer(uuid string) {
+}
diff --git a/services/crunch-dispatch-slurm/crunch-dispatch-slurm.go b/services/crunch-dispatch-slurm/crunch-dispatch-slurm.go
index 617b076..7cb14fa 100644
--- a/services/crunch-dispatch-slurm/crunch-dispatch-slurm.go
+++ b/services/crunch-dispatch-slurm/crunch-dispatch-slurm.go
@@ -11,6 +11,7 @@ import (
 	"math"
 	"os"
 	"os/exec"
+	"regexp"
 	"strings"
 	"time"
 
@@ -122,9 +123,34 @@ func doMain() error {
 		log.Printf("Error notifying init daemon: %v", err)
 	}
 
+	containerTrackerTicker := trackContainers(dispatcher)
+	defer containerTrackerTicker.Stop()
+
 	return dispatcher.Run(context.Background())
 }
 
+var containerUuidPattern = regexp.MustCompile(`[a-z0-9]{5}-dz642-[a-z0-9]{15}$`)
+
+// Start a goroutine to check squeue report periodically, and
+// invoke TrackContainer for all the containers in the report.
+func trackContainers(dispatcher *dispatch.Dispatcher) *time.Ticker {
+	ticker := time.NewTicker(sqCheck.Period)
+	go func() {
+		for {
+			select {
+			case <-ticker.C:
+				for uuid := range sqCheck.AllUuids() {
+					match := containerUuidPattern.MatchString(uuid)
+					if match {
+						dispatcher.TrackContainer(uuid)
+					}
+				}
+			}
+		}
+	}()
+	return ticker
+}
+
 // sbatchCmd
 func sbatchFunc(container arvados.Container) *exec.Cmd {
 	memPerCPU := math.Ceil(float64(container.RuntimeConstraints.RAM) / (float64(container.RuntimeConstraints.VCPUs) * 1048576))
diff --git a/services/crunch-dispatch-slurm/squeue.go b/services/crunch-dispatch-slurm/squeue.go
index 3bebe56..0c90679 100644
--- a/services/crunch-dispatch-slurm/squeue.go
+++ b/services/crunch-dispatch-slurm/squeue.go
@@ -13,7 +13,7 @@ import (
 // command 'squeue'.
 type SqueueChecker struct {
 	Period    time.Duration
-	hasUUID   map[string]bool
+	uuids     map[string]bool
 	startOnce sync.Once
 	done      chan struct{}
 	sync.Cond
@@ -36,7 +36,7 @@ func (sqc *SqueueChecker) HasUUID(uuid string) bool {
 
 	// block until next squeue broadcast signaling an update.
 	sqc.Wait()
-	return sqc.hasUUID[uuid]
+	return sqc.uuids[uuid]
 }
 
 // Stop stops the squeue monitoring goroutine. Do not call HasUUID
@@ -48,7 +48,7 @@ func (sqc *SqueueChecker) Stop() {
 }
 
 // check gets the names of jobs in the SLURM queue (running and
-// queued). If it succeeds, it updates squeue.hasUUID and wakes up any
+// queued). If it succeeds, it updates squeue.uuids and wakes up any
 // goroutines that are waiting in HasUUID().
 func (sqc *SqueueChecker) check() {
 	// Mutex between squeue sync and running sbatch or scancel.  This
@@ -67,9 +67,9 @@ func (sqc *SqueueChecker) check() {
 	}
 
 	uuids := strings.Split(stdout.String(), "\n")
-	sqc.hasUUID = make(map[string]bool, len(uuids))
+	sqc.uuids = make(map[string]bool, len(uuids))
 	for _, uuid := range uuids {
-		sqc.hasUUID[uuid] = true
+		sqc.uuids[uuid] = true
 	}
 	sqc.Broadcast()
 }
@@ -92,3 +92,8 @@ func (sqc *SqueueChecker) start() {
 		}
 	}()
 }
+
+// All Uuids in squeue
+func (sqc *SqueueChecker) AllUuids() map[string]bool {
+	return sqc.uuids
+}

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list