@@ -400,12 +400,8 @@ func (r *WorkerReconciler) failUpdate(ctx context.Context, w *v1beta1.Worker, ms
400400// reconcileDesiredState compares the desired lifecycle state (spec.state) with
401401// the actual backend state and takes corrective action when drift is detected.
402402func (r * WorkerReconciler ) reconcileDesiredState (ctx context.Context , w * v1beta1.Worker , desired string ) (reconcile.Result , error ) {
403- // If current phase already matches desired state, verify the pod still exists.
404- // The pod may have been deleted externally (e.g. kubectl delete pod) while
405- // the CR status still shows Running.
406- if w .Status .Phase == desired && desired == "Running" {
407- return r .ensurePodExists (ctx , w )
408- }
403+ // If current phase already matches desired state, nothing to do.
404+ // This also avoids unnecessary backend Status calls on every reconcile.
409405 if w .Status .Phase == desired {
410406 return reconcile.Result {}, nil
411407 }
@@ -575,34 +571,6 @@ func (r *WorkerReconciler) failLifecycle(ctx context.Context, w *v1beta1.Worker,
575571 return reconcile.Result {RequeueAfter : time .Minute }, fmt .Errorf ("%s" , msg )
576572}
577573
578- // ensurePodExists checks if the worker's pod/container still exists.
579- // If the pod was deleted externally while the CR status is Running,
580- // this triggers recreation via ensureWorkerRunning.
581- func (r * WorkerReconciler ) ensurePodExists (ctx context.Context , w * v1beta1.Worker ) (reconcile.Result , error ) {
582- if r .Backend == nil {
583- return reconcile.Result {}, nil
584- }
585- wb := r .Backend .DetectWorkerBackend (ctx )
586- if wb == nil {
587- return reconcile.Result {}, nil
588- }
589-
590- result , err := wb .Status (ctx , w .Name )
591- if err != nil {
592- // Backend error — don't panic, just requeue
593- return reconcile.Result {RequeueAfter : reconcileRetryDelay }, nil
594- }
595-
596- if result .Status == backend .StatusRunning || result .Status == backend .StatusStarting {
597- return reconcile.Result {}, nil // pod exists, all good
598- }
599-
600- // Pod is gone — trigger recreation
601- logger := log .FromContext (ctx )
602- logger .Info ("pod missing for Running worker, recreating" , "name" , w .Name , "backendStatus" , result .Status )
603- return r .ensureWorkerRunning (ctx , w )
604- }
605-
606574func (r * WorkerReconciler ) SetupWithManager (mgr ctrl.Manager ) error {
607575 builder := ctrl .NewControllerManagedBy (mgr ).
608576 For (& v1beta1.Worker {})
0 commit comments