X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/ca6c0353c236d5fc0f829880e845cbd8489ea9ad..3a9428dd1db2fd393dd90cd3ffc744c0bf45fe28:/lib/dispatchcloud/test/queue.go diff --git a/lib/dispatchcloud/test/queue.go b/lib/dispatchcloud/test/queue.go index fcb2cfb33b..2be8246bd6 100644 --- a/lib/dispatchcloud/test/queue.go +++ b/lib/dispatchcloud/test/queue.go @@ -24,6 +24,9 @@ type Queue struct { // must not be nil. ChooseType func(*arvados.Container) (arvados.InstanceType, error) + // Mimic railsapi implementation of MaxDispatchAttempts config + MaxDispatchAttempts int + Logger logrus.FieldLogger entries map[string]container.QueueEnt @@ -133,7 +136,15 @@ func (q *Queue) changeState(uuid string, from, to arvados.ContainerState) error q.entries[uuid] = ent for i, ctr := range q.Containers { if ctr.UUID == uuid { - q.Containers[i].State = to + if max := q.MaxDispatchAttempts; max > 0 && ctr.LockCount >= max && to == arvados.ContainerStateQueued { + q.Containers[i].State = arvados.ContainerStateCancelled + q.Containers[i].RuntimeStatus = map[string]interface{}{"error": fmt.Sprintf("Failed to start: lock_count == %d", ctr.LockCount)} + } else { + q.Containers[i].State = to + if to == arvados.ContainerStateLocked { + q.Containers[i].LockCount++ + } + } break } } @@ -157,6 +168,7 @@ func (q *Queue) Update() error { upd[ctr.UUID] = ent } else { it, _ := q.ChooseType(&ctr) + ctr.Mounts = nil upd[ctr.UUID] = container.QueueEnt{ Container: ctr, InstanceType: it,