@@ -2,6 +2,7 @@ package app
2
2
3
3
import (
4
4
v1 "github.com/kube-queue/pytorch-operator-extension/pkg/pytorch-operator/apis/pytorch/v1"
5
+ "k8s.io/client-go/kubernetes"
5
6
"k8s.io/client-go/rest"
6
7
"k8s.io/client-go/tools/cache"
7
8
"k8s.io/client-go/tools/clientcmd"
@@ -17,11 +18,6 @@ import (
17
18
"k8s.io/klog/v2"
18
19
)
19
20
20
- const (
21
- ConsumerRefKind = v1 .Kind
22
- ConsumerRefAPIVersion = v1 .GroupName + "/" + v1 .GroupVersion
23
- )
24
-
25
21
// Run runs the server.
26
22
func Run (opt * options.ServerOption ) error {
27
23
var restConfig * rest.Config
@@ -35,6 +31,11 @@ func Run(opt *options.ServerOption) error {
35
31
}
36
32
}
37
33
34
+ k8sClientSet , err := kubernetes .NewForConfig (restConfig )
35
+ if err != nil {
36
+ return err
37
+ }
38
+
38
39
queueClient , err := queueversioned .NewForConfig (restConfig )
39
40
if err != nil {
40
41
return err
@@ -50,7 +51,9 @@ func Run(opt *options.ServerOption) error {
50
51
pytorchJobInformerFactory := pytorchjobinformers .NewSharedInformerFactory (pytorchJobClient , 0 )
51
52
pytorchJobInformer := pytorchJobInformerFactory .Kubeflow ().V1 ().PyTorchJobs ().Informer ()
52
53
53
- pytorchExtensionController := contorller .NewPyTorchExtensionController (queueInformerFactory .Scheduling ().V1alpha1 ().QueueUnits (),
54
+ pytorchExtensionController := contorller .NewPyTorchExtensionController (
55
+ k8sClientSet ,
56
+ queueInformerFactory .Scheduling ().V1alpha1 ().QueueUnits (),
54
57
queueClient ,
55
58
pytorchJobInformerFactory .Kubeflow ().V1 ().PyTorchJobs (),
56
59
pytorchJobClient ,
@@ -62,8 +65,8 @@ func Run(opt *options.ServerOption) error {
62
65
switch qu := obj .(type ) {
63
66
case * v1alpha1.QueueUnit :
64
67
if qu .Spec .ConsumerRef != nil &&
65
- qu .Spec .ConsumerRef .Kind == ConsumerRefKind &&
66
- qu .Spec .ConsumerRef .APIVersion == ConsumerRefAPIVersion {
68
+ qu .Spec .ConsumerRef .Kind == contorller . ConsumerRefKind &&
69
+ qu .Spec .ConsumerRef .APIVersion == contorller . ConsumerRefAPIVersion {
67
70
return true
68
71
}
69
72
return false
@@ -90,9 +93,9 @@ func Run(opt *options.ServerOption) error {
90
93
}
91
94
},
92
95
Handler : cache.ResourceEventHandlerFuncs {
93
- AddFunc : pytorchExtensionController .AddPytorchJob ,
94
- UpdateFunc : pytorchExtensionController .UpdatePytorchJob ,
95
- DeleteFunc : pytorchExtensionController .DeletePytorchJob ,
96
+ AddFunc : pytorchExtensionController .AddPyTorchJob ,
97
+ UpdateFunc : pytorchExtensionController .UpdatePyTorchJob ,
98
+ DeleteFunc : pytorchExtensionController .DeletePyTorchJob ,
96
99
},
97
100
},
98
101
)
0 commit comments