|
5 | 5 | "fmt"
|
6 | 6 | "os"
|
7 | 7 | "reflect"
|
| 8 | + "runtime" |
8 | 9 | "strconv"
|
9 | 10 | "strings"
|
10 | 11 | "time"
|
@@ -32,7 +33,7 @@ import (
|
32 | 33 | networkingv1 "k8s.io/api/networking/v1"
|
33 | 34 | "k8s.io/apimachinery/pkg/api/errors"
|
34 | 35 | "k8s.io/apimachinery/pkg/api/resource"
|
35 |
| - "k8s.io/apimachinery/pkg/runtime" |
| 36 | + k8sruntime "k8s.io/apimachinery/pkg/runtime" |
36 | 37 | ctrl "sigs.k8s.io/controller-runtime"
|
37 | 38 | "sigs.k8s.io/controller-runtime/pkg/builder"
|
38 | 39 | "sigs.k8s.io/controller-runtime/pkg/client"
|
@@ -119,7 +120,7 @@ var _ reconcile.Reconciler = &RayClusterReconciler{}
|
119 | 120 | // RayClusterReconciler reconciles a RayCluster object
|
120 | 121 | type RayClusterReconciler struct {
|
121 | 122 | client.Client
|
122 |
| - Scheme *runtime.Scheme |
| 123 | + Scheme *k8sruntime.Scheme |
123 | 124 | Recorder record.EventRecorder
|
124 | 125 | BatchSchedulerMgr *batchscheduler.SchedulerManager
|
125 | 126 |
|
@@ -306,26 +307,14 @@ func (r *RayClusterReconciler) rayClusterReconcile(ctx context.Context, request
|
306 | 307 | r.reconcileIngress,
|
307 | 308 | r.reconcileHeadService,
|
308 | 309 | r.reconcileHeadlessService,
|
309 |
| - // reconcileServeService |
310 |
| - func(ctx context.Context, instance *rayv1.RayCluster) error { |
311 |
| - // Only reconcile the K8s service for Ray Serve when the "ray.io/enable-serve-service" annotation is set to true. |
312 |
| - if enableServeServiceValue, exist := instance.Annotations[utils.EnableServeServiceKey]; exist && enableServeServiceValue == utils.EnableServeServiceTrue { |
313 |
| - return r.reconcileServeService(ctx, instance) |
314 |
| - } |
315 |
| - return nil |
316 |
| - }, |
317 |
| - // reconcilePods |
318 |
| - func(ctx context.Context, instance *rayv1.RayCluster) error { |
319 |
| - err := r.reconcilePods(ctx, instance) |
320 |
| - if err != nil { |
321 |
| - r.Recorder.Event(instance, corev1.EventTypeWarning, string(rayv1.PodReconciliationError), err.Error()) |
322 |
| - } |
323 |
| - return err |
324 |
| - }, |
| 310 | + r.reconcileServeService, |
| 311 | + r.reconcilePods, |
325 | 312 | }
|
326 | 313 |
|
327 | 314 | for _, fn := range reconcileFuncs {
|
328 | 315 | if reconcileErr = fn(ctx, instance); reconcileErr != nil {
|
| 316 | + funcName := runtime.FuncForPC(reflect.ValueOf(fn).Pointer()).Name() |
| 317 | + logger.Error(reconcileErr, "Error reconcile resources", "function name", funcName) |
329 | 318 | break
|
330 | 319 | }
|
331 | 320 | }
|
@@ -538,6 +527,11 @@ func (r *RayClusterReconciler) reconcileHeadService(ctx context.Context, instanc
|
538 | 527 |
|
539 | 528 | // Return nil only when the serve service successfully created or already exists.
|
540 | 529 | func (r *RayClusterReconciler) reconcileServeService(ctx context.Context, instance *rayv1.RayCluster) error {
|
| 530 | + // Only reconcile the K8s service for Ray Serve when the "ray.io/enable-serve-service" annotation is set to true. |
| 531 | + if enableServeServiceValue, exist := instance.Annotations[utils.EnableServeServiceKey]; !exist || enableServeServiceValue != utils.EnableServeServiceTrue { |
| 532 | + return nil |
| 533 | + } |
| 534 | + |
541 | 535 | // Retrieve the Service from the Kubernetes cluster with the name and namespace.
|
542 | 536 | svc := &corev1.Service{}
|
543 | 537 | err := r.Get(ctx, common.RayClusterServeServiceNamespacedName(instance), svc)
|
|
0 commit comments