X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/498d29adee40f671fd2924c410226db7a6a0ba93..4dde672661ea9dca680ec9eb1cdba7bd7d87fca7:/services/crunch-dispatch-slurm/squeue.go diff --git a/services/crunch-dispatch-slurm/squeue.go b/services/crunch-dispatch-slurm/squeue.go index d15489b278..b8e3108c7c 100644 --- a/services/crunch-dispatch-slurm/squeue.go +++ b/services/crunch-dispatch-slurm/squeue.go @@ -51,17 +51,19 @@ 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 { + 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 @@ -132,11 +134,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()