diff --git a/pkg/scheduler/placement/placement.go b/pkg/scheduler/placement/placement.go index 10e3e663a..7cc8fed43 100644 --- a/pkg/scheduler/placement/placement.go +++ b/pkg/scheduler/placement/placement.go @@ -183,6 +183,16 @@ func (m *AppPlacementManager) PlaceApplication(app *objects.Application) error { queueName = "" continue } + // Check if the queue in Draining state, and if so, proceed to the next rule + if queue.IsDraining() { + log.Log(log.SchedApplication).Debug("Cannot place application in draining queue", + zap.String("queueName", queueName), + zap.String("ruleName", checkRule.getName()), + zap.String("application", app.ApplicationID)) + // reset the queue name for the last rule in the chain + queueName = "" + continue + } } // we have a queue that allows submitting and can be created: app placed log.Log(log.SchedApplication).Info("Rule result for placing application", diff --git a/pkg/scheduler/placement/placement_test.go b/pkg/scheduler/placement/placement_test.go index 9ea73a789..f0bef0040 100644 --- a/pkg/scheduler/placement/placement_test.go +++ b/pkg/scheduler/placement/placement_test.go @@ -323,6 +323,15 @@ partitions: if err == nil || queueName != "" { t.Errorf("parent queue: app should not have been placed, queue: '%s', error: %v", queueName, err) } + + // provided rule (2nd): submit to draining queue + app = newApplication("app1", "default", "root.testparent.testchild", user, nil, nil, "") + man.queueFn("root.testparent.testchild").MarkQueueForRemoval() + err = man.PlaceApplication(app) + queueName = app.GetQueuePath() + if err == nil || queueName != "" { + t.Errorf("draining queue: app should not have been placed, queue: '%s', error: %v", queueName, err) + } } //nolint:funlen