@@ -41,16 +41,15 @@ import (
41
41
"k8s.io/client-go/tools/clientcmd"
42
42
43
43
kbv1 "github.com/kubernetes-sigs/kube-batch/pkg/apis/scheduling/v1alpha1"
44
- "github.com/kubernetes-sigs/kube-batch/pkg/client/clientset/versioned"
45
- arbapi "github.com/kubernetes-sigs/kube-batch/pkg/scheduler/api"
44
+ kbver "github.com/kubernetes-sigs/kube-batch/pkg/client/clientset/versioned"
45
+ kbapi "github.com/kubernetes-sigs/kube-batch/pkg/scheduler/api"
46
46
)
47
47
48
48
var oneMinute = 1 * time .Minute
49
49
50
50
var halfCPU = v1.ResourceList {"cpu" : resource .MustParse ("500m" )}
51
51
var oneCPU = v1.ResourceList {"cpu" : resource .MustParse ("1000m" )}
52
52
var twoCPU = v1.ResourceList {"cpu" : resource .MustParse ("2000m" )}
53
- var threeCPU = v1.ResourceList {"cpu" : resource .MustParse ("3000m" )}
54
53
55
54
const (
56
55
workerPriority = "worker-pri"
@@ -66,7 +65,7 @@ func homeDir() string {
66
65
67
66
type context struct {
68
67
kubeclient * kubernetes.Clientset
69
- karclient * versioned .Clientset
68
+ kbclient * kbver .Clientset
70
69
71
70
namespace string
72
71
queues []string
@@ -86,7 +85,7 @@ func initTestContext() *context {
86
85
config , err := clientcmd .BuildConfigFromFlags ("" , filepath .Join (home , ".kube" , "config" ))
87
86
Expect (err ).NotTo (HaveOccurred ())
88
87
89
- cxt .karclient = versioned .NewForConfigOrDie (config )
88
+ cxt .kbclient = kbver .NewForConfigOrDie (config )
90
89
cxt .kubeclient = kubernetes .NewForConfigOrDie (config )
91
90
92
91
cxt .enableNamespaceAsQueue = enableNamespaceAsQueue
@@ -138,7 +137,7 @@ func queueNotExist(ctx *context) wait.ConditionFunc {
138
137
if ctx .enableNamespaceAsQueue {
139
138
_ , err = ctx .kubeclient .CoreV1 ().Namespaces ().Get (q , metav1.GetOptions {})
140
139
} else {
141
- _ , err = ctx .karclient .Scheduling ().Queues ().Get (q , metav1.GetOptions {})
140
+ _ , err = ctx .kbclient .Scheduling ().Queues ().Get (q , metav1.GetOptions {})
142
141
}
143
142
144
143
if ! (err != nil && errors .IsNotFound (err )) {
@@ -190,7 +189,7 @@ func createQueues(cxt *context) {
190
189
},
191
190
})
192
191
} else {
193
- _ , err = cxt .karclient .Scheduling ().Queues ().Create (& kbv1.Queue {
192
+ _ , err = cxt .kbclient .Scheduling ().Queues ().Create (& kbv1.Queue {
194
193
ObjectMeta : metav1.ObjectMeta {
195
194
Name : q ,
196
195
},
@@ -204,7 +203,7 @@ func createQueues(cxt *context) {
204
203
}
205
204
206
205
if ! cxt .enableNamespaceAsQueue {
207
- _ , err := cxt .karclient .Scheduling ().Queues ().Create (& kbv1.Queue {
206
+ _ , err := cxt .kbclient .Scheduling ().Queues ().Create (& kbv1.Queue {
208
207
ObjectMeta : metav1.ObjectMeta {
209
208
Name : cxt .namespace ,
210
209
},
@@ -228,7 +227,7 @@ func deleteQueues(cxt *context) {
228
227
PropagationPolicy : & foreground ,
229
228
})
230
229
} else {
231
- err = cxt .karclient .Scheduling ().Queues ().Delete (q , & metav1.DeleteOptions {
230
+ err = cxt .kbclient .Scheduling ().Queues ().Delete (q , & metav1.DeleteOptions {
232
231
PropagationPolicy : & foreground ,
233
232
})
234
233
}
@@ -237,7 +236,7 @@ func deleteQueues(cxt *context) {
237
236
}
238
237
239
238
if ! cxt .enableNamespaceAsQueue {
240
- err := cxt .karclient .Scheduling ().Queues ().Delete (cxt .namespace , & metav1.DeleteOptions {
239
+ err := cxt .kbclient .Scheduling ().Queues ().Delete (cxt .namespace , & metav1.DeleteOptions {
241
240
PropagationPolicy : & foreground ,
242
241
})
243
242
@@ -334,15 +333,15 @@ func createJobEx(context *context, job *jobSpec) ([]*batchv1.Job, *kbv1.PodGroup
334
333
pg .Spec .MinMember = * job .minMember
335
334
}
336
335
337
- podgroup , err := context .karclient .Scheduling ().PodGroups (pg .Namespace ).Create (pg )
336
+ podgroup , err := context .kbclient .Scheduling ().PodGroups (pg .Namespace ).Create (pg )
338
337
Expect (err ).NotTo (HaveOccurred ())
339
338
340
339
return jobs , podgroup
341
340
}
342
341
343
342
func taskPhase (ctx * context , pg * kbv1.PodGroup , phase []v1.PodPhase , taskNum int ) wait.ConditionFunc {
344
343
return func () (bool , error ) {
345
- pg , err := ctx .karclient .Scheduling ().PodGroups (pg .Namespace ).Get (pg .Name , metav1.GetOptions {})
344
+ pg , err := ctx .kbclient .Scheduling ().PodGroups (pg .Namespace ).Get (pg .Name , metav1.GetOptions {})
346
345
Expect (err ).NotTo (HaveOccurred ())
347
346
348
347
pods , err := ctx .kubeclient .CoreV1 ().Pods (pg .Namespace ).List (metav1.ListOptions {})
@@ -368,7 +367,7 @@ func taskPhase(ctx *context, pg *kbv1.PodGroup, phase []v1.PodPhase, taskNum int
368
367
369
368
func taskPhaseEx (ctx * context , pg * kbv1.PodGroup , phase []v1.PodPhase , taskNum map [string ]int ) wait.ConditionFunc {
370
369
return func () (bool , error ) {
371
- pg , err := ctx .karclient .Scheduling ().PodGroups (pg .Namespace ).Get (pg .Name , metav1.GetOptions {})
370
+ pg , err := ctx .kbclient .Scheduling ().PodGroups (pg .Namespace ).Get (pg .Name , metav1.GetOptions {})
372
371
Expect (err ).NotTo (HaveOccurred ())
373
372
374
373
pods , err := ctx .kubeclient .CoreV1 ().Pods (pg .Namespace ).List (metav1.ListOptions {})
@@ -419,7 +418,7 @@ func podGroupUnschedulable(ctx *context, pg *kbv1.PodGroup, time time.Time) wait
419
418
420
419
func podGroupEvicted (ctx * context , pg * kbv1.PodGroup , time time.Time ) wait.ConditionFunc {
421
420
return func () (bool , error ) {
422
- pg , err := ctx .karclient .SchedulingV1alpha1 ().PodGroups (pg .Namespace ).Get (pg .Name , metav1.GetOptions {})
421
+ pg , err := ctx .kbclient .SchedulingV1alpha1 ().PodGroups (pg .Namespace ).Get (pg .Name , metav1.GetOptions {})
423
422
Expect (err ).NotTo (HaveOccurred ())
424
423
425
424
events , err := ctx .kubeclient .CoreV1 ().Events (pg .Namespace ).List (metav1.ListOptions {})
@@ -571,7 +570,7 @@ func clusterSize(ctx *context, req v1.ResourceList) int32 {
571
570
pods , err := ctx .kubeclient .CoreV1 ().Pods (metav1 .NamespaceAll ).List (metav1.ListOptions {})
572
571
Expect (err ).NotTo (HaveOccurred ())
573
572
574
- used := map [string ]* arbapi .Resource {}
573
+ used := map [string ]* kbapi .Resource {}
575
574
576
575
for _ , pod := range pods .Items {
577
576
nodeName := pod .Spec .NodeName
@@ -584,11 +583,11 @@ func clusterSize(ctx *context, req v1.ResourceList) int32 {
584
583
}
585
584
586
585
if _ , found := used [nodeName ]; ! found {
587
- used [nodeName ] = arbapi .EmptyResource ()
586
+ used [nodeName ] = kbapi .EmptyResource ()
588
587
}
589
588
590
589
for _ , c := range pod .Spec .Containers {
591
- req := arbapi .NewResource (c .Resources .Requests )
590
+ req := kbapi .NewResource (c .Resources .Requests )
592
591
used [nodeName ].Add (req )
593
592
}
594
593
}
@@ -601,8 +600,8 @@ func clusterSize(ctx *context, req v1.ResourceList) int32 {
601
600
continue
602
601
}
603
602
604
- alloc := arbapi .NewResource (node .Status .Allocatable )
605
- slot := arbapi .NewResource (req )
603
+ alloc := kbapi .NewResource (node .Status .Allocatable )
604
+ slot := kbapi .NewResource (req )
606
605
607
606
// Removed used resources.
608
607
if res , found := used [node .Name ]; found {
@@ -640,7 +639,7 @@ func computeNode(ctx *context, req v1.ResourceList) (string, int32) {
640
639
pods , err := ctx .kubeclient .CoreV1 ().Pods (metav1 .NamespaceAll ).List (metav1.ListOptions {})
641
640
Expect (err ).NotTo (HaveOccurred ())
642
641
643
- used := map [string ]* arbapi .Resource {}
642
+ used := map [string ]* kbapi .Resource {}
644
643
645
644
for _ , pod := range pods .Items {
646
645
nodeName := pod .Spec .NodeName
@@ -653,11 +652,11 @@ func computeNode(ctx *context, req v1.ResourceList) (string, int32) {
653
652
}
654
653
655
654
if _ , found := used [nodeName ]; ! found {
656
- used [nodeName ] = arbapi .EmptyResource ()
655
+ used [nodeName ] = kbapi .EmptyResource ()
657
656
}
658
657
659
658
for _ , c := range pod .Spec .Containers {
660
- req := arbapi .NewResource (c .Resources .Requests )
659
+ req := kbapi .NewResource (c .Resources .Requests )
661
660
used [nodeName ].Add (req )
662
661
}
663
662
}
@@ -669,8 +668,8 @@ func computeNode(ctx *context, req v1.ResourceList) (string, int32) {
669
668
670
669
res := int32 (0 )
671
670
672
- alloc := arbapi .NewResource (node .Status .Allocatable )
673
- slot := arbapi .NewResource (req )
671
+ alloc := kbapi .NewResource (node .Status .Allocatable )
672
+ slot := kbapi .NewResource (req )
674
673
675
674
// Removed used resources.
676
675
if res , found := used [node .Name ]; found {
@@ -691,7 +690,7 @@ func computeNode(ctx *context, req v1.ResourceList) (string, int32) {
691
690
}
692
691
693
692
func getPodOfPodGroup (ctx * context , pg * kbv1.PodGroup ) []* v1.Pod {
694
- pg , err := ctx .karclient .Scheduling ().PodGroups (pg .Namespace ).Get (pg .Name , metav1.GetOptions {})
693
+ pg , err := ctx .kbclient .Scheduling ().PodGroups (pg .Namespace ).Get (pg .Name , metav1.GetOptions {})
695
694
Expect (err ).NotTo (HaveOccurred ())
696
695
697
696
pods , err := ctx .kubeclient .CoreV1 ().Pods (pg .Namespace ).List (metav1.ListOptions {})
0 commit comments