Skip to content

Commit e5d89a7

Browse files
committed
move release code up in call stack
1 parent d164287 commit e5d89a7

File tree

2 files changed

+7
-32
lines changed

2 files changed

+7
-32
lines changed

pkg/controller/queuejob/queuejob_controller_ex.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,6 +1025,8 @@ func (qjm *XController) chooseAgent(qj *arbv1.AppWrapper) string {
10251025
//Now evaluate quota
10261026
if qjm.serverOption.QuotaEnabled {
10271027
if qjm.quotaManager != nil {
1028+
//quota trees faile to update with AW deletes, release quota before assigning
1029+
qjm.quotaManager.Release(qj)
10281030
if fits, preemptAWs, _ := qjm.quotaManager.Fits(qj, qjAggrResources, proposedPreemptions); fits {
10291031
klog.V(2).Infof("[chooseAgent] AppWrapper %s has enough quota.\n", qj.Name)
10301032
qjm.preemptAWJobs(preemptAWs)
@@ -1256,6 +1258,8 @@ func (qjm *XController) ScheduleNext() {
12561258
klog.V(10).Infof("[ScheduleNext] HOL available resourse successful check for %s at %s activeQ=%t Unsched=%t &qj=%p Version=%s Status=%+v due to quota limits", qj.Name, time.Now().Sub(HOLStartTime), qjm.qjqueue.IfExistActiveQ(qj), qjm.qjqueue.IfExistUnschedulableQ(qj), qj, qj.ResourceVersion, qj.Status)
12571259
if qjm.serverOption.QuotaEnabled {
12581260
if qjm.quotaManager != nil {
1261+
//quota trees faile to update with AW deletes, release quota before assigning
1262+
qjm.quotaManager.Release(qj)
12591263
quotaFits, preemptAWs, msg := qjm.quotaManager.Fits(qj, aggqj, proposedPreemptions)
12601264
if quotaFits {
12611265
klog.V(4).Infof("[ScheduleNext] HOL quota evaluation successful %s for %s activeQ=%t Unsched=%t &qj=%p Version=%s Status=%+v due to quota limits", qj.Name, time.Now().Sub(HOLStartTime), qjm.qjqueue.IfExistActiveQ(qj), qjm.qjqueue.IfExistUnschedulableQ(qj), qj, qj.ResourceVersion, qj.Status)

pkg/quotaplugins/quota-forest/quota-manager/quota/quotamanager.go

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,8 @@ import (
2121
"fmt"
2222
"strings"
2323

24-
clientset "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/clientset/controller-versioned"
2524
"github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/quotaplugins/quota-forest/quota-manager/quota/core"
2625
"github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/quotaplugins/quota-forest/quota-manager/quota/utils"
27-
"github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/quotaplugins/util"
28-
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
29-
"k8s.io/client-go/rest"
3026
"k8s.io/klog/v2"
3127
)
3228

@@ -376,34 +372,9 @@ func (m *Manager) AllocateForest(forestName string, consumerID string) (response
376372
if consumerInfo == nil {
377373
return nil, fmt.Errorf("consumer %s does not exist, create and add first", consumerID)
378374
}
379-
//allocation can pass if consumers inside the forest are not released
380-
//make sure that appwrapper (consumer) does not exist in target namespace
381-
namespace, awName := util.ParseId(consumerID)
382-
config, err := rest.InClusterConfig()
383-
if err != nil {
384-
klog.Errorf("unable to retrieve in-cluster kubeconfig %v", err)
385-
}
386-
arbclients := clientset.NewForConfigOrDie(config)
387-
awQueried, err := arbclients.ArbV1().AppWrappers(namespace).Get(awName, v1.GetOptions{})
388-
var awExistsInNamespace bool = false
389-
if err != nil {
390-
klog.Errorf("Unable to query consumer %v,", consumerID)
391-
//force set to true
392-
awExistsInNamespace = true
393-
}
394-
if awQueried.Name == awName {
395-
awExistsInNamespace = true
396-
klog.V(5).Infof("[AllocateForest] Found consumer %v in namespace", consumerID)
397-
}
398-
if awExistsInNamespace {
399-
if forestController.IsConsumerAllocated(consumerID) {
400-
return nil, fmt.Errorf("consumer %s already allocated on forest %s", consumerID, forestName)
401-
}
402-
} else {
403-
if forestController.IsConsumerAllocated(consumerID) {
404-
klog.V(4).Infof("[AllocateForest] Found consumer %v in quota tree but didn't find its matching AppWrapper. Deleting consumer from the tree", consumerID)
405-
m.DeAllocateForest(forestName, consumerID)
406-
}
375+
376+
if forestController.IsConsumerAllocated(consumerID) {
377+
return nil, fmt.Errorf("consumer %s already allocated on forest %s", consumerID, forestName)
407378
}
408379

409380
resourceNames := forestController.GetResourceNames()

0 commit comments

Comments
 (0)