@@ -365,31 +365,35 @@ func (w *wlReconciler) reconcileGroup(ctx context.Context, group *wlGroup) (reco
365365 // We'll retry this in the next reconciling.
366366 return reconcile.Result {}, err
367367 }
368- } else {
369- // workload eviction on worker cluster
370- log .V (3 ).Info ("Workload gets evicted in the remote cluster" , "cluster" , evictedRemote )
368+ return reconcile.Result {}, nil
369+ }
371370
372- for cluster := range group .remotes {
373- err := group .RemoveRemoteObjects (ctx , cluster )
374- if err != nil {
375- return reconcile.Result {}, err
376- }
371+ // workload eviction on worker cluster
372+ log .V (3 ).Info ("Workload gets evicted in the remote cluster" , "cluster" , evictedRemote )
373+
374+ needsACUpdate := acs .State == kueue .CheckStateReady
375+ if err := workload .PatchAdmissionStatus (ctx , w .client , group .local , w .clock , func (wl * kueue.Workload ) (bool , error ) {
376+ if needsACUpdate {
377+ acs .State = kueue .CheckStatePending
378+ acs .Message = fmt .Sprintf ("Workload evicted on worker cluster: %q, resetting for re-admission" , * group .local .Status .ClusterName )
379+ acs .LastTransitionTime = metav1 .NewTime (w .clock .Now ())
380+ workload .SetAdmissionCheckState (& wl .Status .AdmissionChecks , * acs , w .clock )
381+ wl .Status .ClusterName = nil
382+ wl .Status .NominatedClusterNames = nil
377383 }
378- needsACUpdate := acs .State == kueue .CheckStateReady
379- if err := workload .PatchAdmissionStatus (ctx , w .client , group .local , w .clock , func (wl * kueue.Workload ) (bool , error ) {
380- if needsACUpdate {
381- acs .State = kueue .CheckStatePending
382- // update the message
383- acs .Message = fmt .Sprintf ("Workload evicted on worker cluster: %q, resetting for re-admission" , * group .local .Status .ClusterName )
384- // update the transition time since is used to detect the lost worker state.
385- acs .LastTransitionTime = metav1 .NewTime (w .clock .Now ())
386- workload .SetAdmissionCheckState (& group .local .Status .AdmissionChecks , * acs , w .clock )
387- group .local .Status .ClusterName = nil
388- group .local .Status .NominatedClusterNames = nil
389- }
390- return true , nil
391- }); err != nil {
392- log .Error (err , "Failed to patch workload status" )
384+ return true , nil
385+ }); err != nil {
386+ log .Error (err , "Failed to patch workload status" )
387+ return reconcile.Result {}, err
388+ }
389+
390+ if needsACUpdate {
391+ w .recorder .Eventf (group .local , corev1 .EventTypeNormal , "MultiKueue" , acs .Message )
392+ }
393+
394+ for cluster := range group .remotes {
395+ if err := client .IgnoreNotFound (group .RemoveRemoteObjects (ctx , cluster )); err != nil {
396+ log .Error (err , "Failed to remove cluster remote objects" , "cluster" , cluster )
393397 return reconcile.Result {}, err
394398 }
395399 }
0 commit comments