20718: Cleans up by running "go mod tidy -compat=1.17"
[arvados.git] / lib / dispatchcloud / scheduler / run_queue.go
index dcb348878dcb5404eac881e6a3301c61a58e4ee1..63ac4a7b32122e68787bad1b71c1c5a988e97440 100644 (file)
@@ -89,8 +89,16 @@ func (sch *Scheduler) runQueue() {
        } else {
                sch.mLast503Time.Set(float64(sch.last503time.Unix()))
        }
+       if sch.maxInstances > 0 && sch.maxConcurrency > sch.maxInstances {
+               sch.maxConcurrency = sch.maxInstances
+       }
        sch.mMaxContainerConcurrency.Set(float64(sch.maxConcurrency))
 
+       maxSupervisors := int(float64(sch.maxConcurrency) * sch.supervisorFraction)
+       if maxSupervisors < 1 && sch.supervisorFraction > 0 && sch.maxConcurrency > 0 {
+               maxSupervisors = 1
+       }
+
        sch.logger.WithFields(logrus.Fields{
                "Containers":     len(sorted),
                "Processes":      len(running),
@@ -118,7 +126,7 @@ tryrun:
                })
                if ctr.SchedulingParameters.Supervisor {
                        supervisors += 1
-                       if sch.maxSupervisors > 0 && supervisors > sch.maxSupervisors {
+                       if maxSupervisors > 0 && supervisors > maxSupervisors {
                                overmaxsuper = append(overmaxsuper, sorted[i])
                                continue
                        }