Skip to content

Commit

Permalink
Check existing pods for suspended RayCluster before calling DeleteCol…
Browse files Browse the repository at this point in the history
…lection (ray-project#1745)
  • Loading branch information
andrewsykim authored Dec 13, 2023
1 parent 1fe5ae7 commit bf3fd63
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions ray-operator/controllers/ray/raycluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,15 @@ func (r *RayClusterReconciler) reconcilePods(ctx context.Context, instance *rayv
// if RayCluster is suspended, delete all pods and skip reconcile
if instance.Spec.Suspend != nil && *instance.Spec.Suspend {
clusterLabel := client.MatchingLabels{utils.RayClusterLabelKey: instance.Name}
allPods := corev1.PodList{}
if err := r.List(ctx, &allPods, client.InNamespace(instance.Namespace), clusterLabel); err != nil {
return err
}

if len(allPods.Items) == 0 {
return nil
}

if err := r.DeleteAllOf(ctx, &corev1.Pod{}, client.InNamespace(instance.Namespace), clusterLabel); err != nil {
return err
}
Expand Down

0 comments on commit bf3fd63

Please sign in to comment.