From 9c74b4ddc1212d0dce658141c9ab51223dc66b29 Mon Sep 17 00:00:00 2001 From: Simone Gotti Date: Wed, 17 Apr 2019 20:59:28 +0200 Subject: [PATCH] runservice scheduler: choose scheduler only if it has capacity --- internal/services/config/config.go | 3 +++ internal/services/runservice/scheduler/scheduler.go | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/internal/services/config/config.go b/internal/services/config/config.go index 04cb4b0..6c2d3f5 100644 --- a/internal/services/config/config.go +++ b/internal/services/config/config.go @@ -182,6 +182,9 @@ var defaultConfig = Config{ RunServiceScheduler: RunServiceScheduler{ RunCacheExpireInterval: 7 * 24 * time.Hour, }, + RunServiceExecutor: RunServiceExecutor{ + ActiveTasksLimit: 2, + }, } func Parse(configFile string) (*Config, error) { diff --git a/internal/services/runservice/scheduler/scheduler.go b/internal/services/runservice/scheduler/scheduler.go index 512d88a..7ca934a 100644 --- a/internal/services/runservice/scheduler/scheduler.go +++ b/internal/services/runservice/scheduler/scheduler.go @@ -293,6 +293,11 @@ func (s *Scheduler) chooseExecutor(ctx context.Context, rct *types.RunConfigTask if e.Labels["arch"] != string(rct.Runtime.Arch) { continue } + if e.ActiveTasksLimit != 0 { + if e.ActiveTasks >= e.ActiveTasksLimit { + continue + } + } } return e, nil