20182: API server sets "supervisor" flag now
[arvados.git] / lib / dispatchcloud / scheduler / run_queue.go
index 057ff8d6e29505fa9319071d1f135a939ef0a83e..b8158579a3a3a1b30a0eccc80b421f8abe8bdecf 100644 (file)
@@ -62,7 +62,11 @@ func (sch *Scheduler) runQueue() {
                        sch.maxConcurrency = max
                }
        }
-       sch.mLast503Time.Set(float64(sch.last503time.Unix()))
+       if sch.last503time.IsZero() {
+               sch.mLast503Time.Set(0)
+       } else {
+               sch.mLast503Time.Set(float64(sch.last503time.Unix()))
+       }
        sch.mMaxContainerConcurrency.Set(float64(sch.maxConcurrency))
 
        sch.logger.WithFields(logrus.Fields{
@@ -80,6 +84,8 @@ func (sch *Scheduler) runQueue() {
        // reaches the dynamic maxConcurrency limit.
        trying := len(running)
 
+       supervisors := 0
+
 tryrun:
        for i, ctr := range sorted {
                ctr, it := ctr.Container, ctr.InstanceType
@@ -87,6 +93,12 @@ tryrun:
                        "ContainerUUID": ctr.UUID,
                        "InstanceType":  it.Name,
                })
+               if ctr.SchedulingParameters.Supervisor {
+                       supervisors += 1
+                       if sch.maxSupervisors > 0 && supervisors > sch.maxSupervisors {
+                               continue
+                       }
+               }
                if _, running := running[ctr.UUID]; running || ctr.Priority < 1 {
                        continue
                }
@@ -150,8 +162,10 @@ tryrun:
                        } else if sch.pool.KillContainer(ctr.UUID, "about to start") {
                                logger.Info("not restarting yet: crunch-run process from previous attempt has not exited")
                        } else if sch.pool.StartContainer(it, ctr) {
+                               logger.Trace("StartContainer => true")
                                // Success.
                        } else {
+                               logger.Trace("StartContainer => false")
                                containerAllocatedWorkerBootingCount += 1
                                dontstart[it] = true
                        }