@@ -31,6 +31,7 @@ import (
3131 "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
3232 "sigs.k8s.io/controller-runtime/pkg/handler"
3333 "sigs.k8s.io/controller-runtime/pkg/manager"
34+ "sigs.k8s.io/controller-runtime/pkg/predicate"
3435 "sigs.k8s.io/controller-runtime/pkg/reconcile"
3536 "sigs.k8s.io/controller-runtime/pkg/source"
3637)
@@ -214,6 +215,10 @@ func (r *RayClusterReconciler) rayClusterReconcile(request ctrl.Request, instanc
214215 if updateErr := r .updateClusterState (instance , rayiov1alpha1 .Failed ); updateErr != nil {
215216 r .Log .Error (updateErr , "RayCluster update state error" , "cluster name" , request .Name )
216217 }
218+ if updateErr := r .updateClusterReason (instance , err .Error ()); updateErr != nil {
219+ r .Log .Error (updateErr , "RayCluster update reason error" , "cluster name" , request .Name )
220+ }
221+ r .Recorder .Event (instance , corev1 .EventTypeWarning , string (rayiov1alpha1 .PodReconciliationError ), err .Error ())
217222 return ctrl.Result {RequeueAfter : DefaultRequeueDuration }, err
218223 }
219224 // update the status if needed
@@ -762,6 +767,7 @@ func (r *RayClusterReconciler) buildWorkerPod(instance rayiov1alpha1.RayCluster,
762767func (r * RayClusterReconciler ) SetupWithManager (mgr ctrl.Manager , reconcileConcurrency int ) error {
763768 return ctrl .NewControllerManagedBy (mgr ).
764769 For (& rayiov1alpha1.RayCluster {}).Named ("raycluster-controller" ).
770+ WithEventFilter (predicate .Or (predicate.GenerationChangedPredicate {}, predicate.LabelChangedPredicate {}, predicate.AnnotationChangedPredicate {})).
765771 Watches (& source.Kind {Type : & corev1.Event {}}, & handler.EnqueueRequestForObject {}).
766772 Watches (& source.Kind {Type : & corev1.Pod {}}, & handler.EnqueueRequestForOwner {
767773 IsController : true ,
@@ -1049,3 +1055,8 @@ func (r *RayClusterReconciler) updateClusterState(instance *rayiov1alpha1.RayClu
10491055 instance .Status .State = clusterState
10501056 return r .Status ().Update (context .Background (), instance )
10511057}
1058+
1059+ func (r * RayClusterReconciler ) updateClusterReason (instance * rayiov1alpha1.RayCluster , clusterReason string ) error {
1060+ instance .Status .Reason = clusterReason
1061+ return r .Status ().Update (context .Background (), instance )
1062+ }
0 commit comments