14325: Test dispatch container queue against controller.
[arvados.git] / lib / dispatchcloud / test / queue.go
index fda04d52b3b6498e69f98f41a2f1c73696dd3758..e18a2b5362b413a16eeb28984bfabbe34796f6db 100644 (file)
@@ -95,6 +95,7 @@ func (q *Queue) Unsubscribe(ch <-chan struct{}) {
        delete(q.subscribers, ch)
 }
 
+// caller must have lock.
 func (q *Queue) notify() {
        for _, ch := range q.subscribers {
                select {
@@ -133,10 +134,15 @@ func (q *Queue) Update() error {
                if !exists && (ctr.State == arvados.ContainerStateComplete || ctr.State == arvados.ContainerStateCancelled) {
                        continue
                }
-               it, _ := q.ChooseType(&ctr)
-               upd[ctr.UUID] = container.QueueEnt{
-                       Container:    ctr,
-                       InstanceType: it,
+               if ent, ok := upd[ctr.UUID]; ok {
+                       ent.Container = ctr
+                       upd[ctr.UUID] = ent
+               } else {
+                       it, _ := q.ChooseType(&ctr)
+                       upd[ctr.UUID] = container.QueueEnt{
+                               Container:    ctr,
+                               InstanceType: it,
+                       }
                }
        }
        q.entries = upd