@@ -33,7 +33,6 @@ import (
33
33
"sigs.k8s.io/controller-runtime/pkg/predicate"
34
34
"sigs.k8s.io/controller-runtime/pkg/reconcile"
35
35
36
- configapi "github.com/ray-project/kuberay/ray-operator/apis/config/v1alpha1"
37
36
rayv1 "github.com/ray-project/kuberay/ray-operator/apis/ray/v1"
38
37
"github.com/ray-project/kuberay/ray-operator/controllers/ray/batchscheduler"
39
38
"github.com/ray-project/kuberay/ray-operator/controllers/ray/common"
@@ -53,29 +52,18 @@ var (
53
52
)
54
53
55
54
// NewReconciler returns a new reconcile.Reconciler
56
- func NewReconciler (ctx context.Context , mgr manager.Manager , options RayClusterReconcilerOptions , rayConfigs configapi. Configuration ) * RayClusterReconciler {
55
+ func NewReconciler (ctx context.Context , mgr manager.Manager , options RayClusterReconcilerOptions ) * RayClusterReconciler {
57
56
if err := mgr .GetFieldIndexer ().IndexField (ctx , & corev1.Pod {}, podUIDIndexField , func (rawObj client.Object ) []string {
58
57
pod := rawObj .(* corev1.Pod )
59
58
return []string {string (pod .UID )}
60
59
}); err != nil {
61
60
panic (err )
62
61
}
63
62
64
- // init the batch scheduler manager
65
- schedulerMgr , err := batchscheduler .NewSchedulerManager (ctx , rayConfigs , mgr .GetConfig (), mgr .GetClient ())
66
- if err != nil {
67
- // fail fast if the scheduler plugin fails to init
68
- // prevent running the controller in an undefined state
69
- panic (err )
70
- }
71
-
72
- // add schema to runtime
73
- schedulerMgr .AddToScheme (mgr .GetScheme ())
74
63
return & RayClusterReconciler {
75
64
Client : mgr .GetClient (),
76
65
Scheme : mgr .GetScheme (),
77
66
Recorder : mgr .GetEventRecorderFor ("raycluster-controller" ),
78
- BatchSchedulerMgr : schedulerMgr ,
79
67
rayClusterScaleExpectation : expectations .NewRayClusterScaleExpectation (mgr .GetClient ()),
80
68
options : options ,
81
69
}
@@ -86,13 +74,13 @@ type RayClusterReconciler struct {
86
74
client.Client
87
75
Scheme * k8sruntime.Scheme
88
76
Recorder record.EventRecorder
89
- BatchSchedulerMgr * batchscheduler.SchedulerManager
90
77
rayClusterScaleExpectation expectations.RayClusterScaleExpectation
91
78
options RayClusterReconcilerOptions
92
79
}
93
80
94
81
type RayClusterReconcilerOptions struct {
95
82
RayClusterMetricsManager * metrics.RayClusterMetricsManager
83
+ BatchSchedulerManager * batchscheduler.SchedulerManager
96
84
HeadSidecarContainers []corev1.Container
97
85
WorkerSidecarContainers []corev1.Container
98
86
IsOpenShift bool
@@ -592,8 +580,8 @@ func (r *RayClusterReconciler) reconcilePods(ctx context.Context, instance *rayv
592
580
}
593
581
// check if the batch scheduler integration is enabled
594
582
// call the scheduler plugin if so
595
- if r .BatchSchedulerMgr != nil {
596
- if scheduler , err := r .BatchSchedulerMgr .GetSchedulerForCluster (); err == nil {
583
+ if r .options . BatchSchedulerManager != nil {
584
+ if scheduler , err := r .options . BatchSchedulerManager .GetSchedulerForCluster (); err == nil {
597
585
if err := scheduler .DoBatchSchedulingOnSubmission (ctx , instance ); err != nil {
598
586
return err
599
587
}
@@ -935,8 +923,8 @@ func (r *RayClusterReconciler) createHeadPod(ctx context.Context, instance rayv1
935
923
pod := r .buildHeadPod (ctx , instance )
936
924
// check if the batch scheduler integration is enabled
937
925
// call the scheduler plugin if so
938
- if r .BatchSchedulerMgr != nil {
939
- if scheduler , err := r .BatchSchedulerMgr .GetSchedulerForCluster (); err == nil {
926
+ if r .options . BatchSchedulerManager != nil {
927
+ if scheduler , err := r .options . BatchSchedulerManager .GetSchedulerForCluster (); err == nil {
940
928
scheduler .AddMetadataToPod (ctx , & instance , utils .RayNodeHeadGroupLabelValue , & pod )
941
929
} else {
942
930
return err
@@ -958,8 +946,8 @@ func (r *RayClusterReconciler) createWorkerPod(ctx context.Context, instance ray
958
946
959
947
// build the pod then create it
960
948
pod := r .buildWorkerPod (ctx , instance , worker )
961
- if r .BatchSchedulerMgr != nil {
962
- if scheduler , err := r .BatchSchedulerMgr .GetSchedulerForCluster (); err == nil {
949
+ if r .options . BatchSchedulerManager != nil {
950
+ if scheduler , err := r .options . BatchSchedulerManager .GetSchedulerForCluster (); err == nil {
963
951
scheduler .AddMetadataToPod (ctx , & instance , worker .GroupName , & pod )
964
952
} else {
965
953
return err
@@ -1123,8 +1111,8 @@ func (r *RayClusterReconciler) SetupWithManager(mgr ctrl.Manager, reconcileConcu
1123
1111
))).
1124
1112
Owns (& corev1.Pod {}).
1125
1113
Owns (& corev1.Service {})
1126
- if r .BatchSchedulerMgr != nil {
1127
- r .BatchSchedulerMgr .ConfigureReconciler (b )
1114
+ if r .options . BatchSchedulerManager != nil {
1115
+ r .options . BatchSchedulerManager .ConfigureReconciler (b )
1128
1116
}
1129
1117
1130
1118
return b .
0 commit comments