@@ -19,12 +19,12 @@ package quota
19
19
import (
20
20
"bytes"
21
21
"fmt"
22
- "regexp"
23
22
"strings"
24
23
25
24
clientset "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/clientset/controller-versioned"
26
25
"github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/quotaplugins/quota-forest/quota-manager/quota/core"
27
26
"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
28
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
29
29
"k8s.io/client-go/rest"
30
30
"k8s.io/klog/v2"
@@ -369,29 +369,31 @@ func (m *Manager) UpdateForest(forestName string) (unallocatedConsumerIDs []stri
369
369
// AllocateForest : allocate a consumer on a forest
370
370
func (m * Manager ) AllocateForest (forestName string , consumerID string ) (response * core.AllocationResponse , err error ) {
371
371
forestController := m .forests [forestName ]
372
- var awExistsInNamespace bool = false
373
372
if forestController == nil {
374
373
return nil , fmt .Errorf ("invalid forest name %s" , forestName )
375
374
}
376
375
consumerInfo := m .consumerInfos [consumerID ]
377
376
if consumerInfo == nil {
378
377
return nil , fmt .Errorf ("consumer %s does not exist, create and add first" , consumerID )
379
378
}
380
- //allocation can pass if consumers are not released
379
+ //allocation can pass if consumers inside the forest is not released
381
380
//make sure that appwrapper (consumer) does not exist in target namespace
382
- re := regexp .MustCompile ("_" )
383
- split := re .Split (consumerID , - 1 )
384
- namespace := split [1 ]
385
- awName := split [3 ]
381
+ namespace , awName := util .ParseId (consumerID )
386
382
config , err := rest .InClusterConfig ()
387
383
if err != nil {
388
384
klog .Errorf ("unable to retrieve in-cluster kubeconfig %v" , err )
389
385
}
390
386
arbclients := clientset .NewForConfigOrDie (config )
391
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
+ }
392
394
if awQueried .Name == awName {
393
395
awExistsInNamespace = true
394
- klog .V (5 ).Infof ("Found consumer %v in namespace" , consumerID )
396
+ klog .V (5 ).Infof ("[AllocateForest] Found consumer %v in namespace" , consumerID )
395
397
}
396
398
if awExistsInNamespace {
397
399
if forestController .IsConsumerAllocated (consumerID ) {
0 commit comments