@@ -179,22 +179,22 @@ func (r *RayClusterReconciler) Reconcile(ctx context.Context, request ctrl.Reque
179
179
return ctrl.Result {}, client .IgnoreNotFound (err )
180
180
}
181
181
182
- func (r * RayClusterReconciler ) deleteAllPods (ctx context.Context , namespace string , filterLabels client.MatchingLabels ) (active int , pods corev1.PodList , err error ) {
182
+ func (r * RayClusterReconciler ) deleteAllPods (ctx context.Context , namespace string , filterLabels client.MatchingLabels ) (pods corev1.PodList , err error ) {
183
183
logger := ctrl .LoggerFrom (ctx )
184
184
if err = r .List (ctx , & pods , client .InNamespace (namespace ), filterLabels ); err != nil {
185
- return 0 , pods , err
185
+ return pods , err
186
186
}
187
- active = 0
187
+ active : = 0
188
188
for _ , pod := range pods .Items {
189
189
if pod .DeletionTimestamp .IsZero () {
190
190
active ++
191
191
}
192
192
}
193
193
if active > 0 {
194
194
logger .Info ("Deleting all Pods with labels" , "filterLabels" , filterLabels , "Number of active Pods" , active )
195
- return active , pods , r .DeleteAllOf (ctx , & corev1.Pod {}, client .InNamespace (namespace ), filterLabels )
195
+ return pods , r .DeleteAllOf (ctx , & corev1.Pod {}, client .InNamespace (namespace ), filterLabels )
196
196
}
197
- return active , pods , nil
197
+ return pods , nil
198
198
}
199
199
200
200
func (r * RayClusterReconciler ) rayClusterReconcile (ctx context.Context , request ctrl.Request , instance * rayv1.RayCluster ) (ctrl.Result , error ) {
@@ -230,21 +230,21 @@ func (r *RayClusterReconciler) rayClusterReconcile(ctx context.Context, request
230
230
"DeletionTimestamp" , instance .ObjectMeta .DeletionTimestamp )
231
231
232
232
// Delete the head Pod if it exists.
233
- numDeletedHeads , headPods , err := r .deleteAllPods (ctx , instance .Namespace , client.MatchingLabels {
233
+ headPods , err := r .deleteAllPods (ctx , instance .Namespace , client.MatchingLabels {
234
234
utils .RayClusterLabelKey : instance .Name ,
235
235
utils .RayNodeTypeLabelKey : string (rayv1 .HeadNode ),
236
236
})
237
237
if err != nil {
238
238
return ctrl.Result {RequeueAfter : DefaultRequeueDuration }, err
239
239
}
240
240
// Delete all worker Pods if they exist.
241
- if _ , _ , err = r .deleteAllPods (ctx , instance .Namespace , client.MatchingLabels {
241
+ if _ , err = r .deleteAllPods (ctx , instance .Namespace , client.MatchingLabels {
242
242
utils .RayClusterLabelKey : instance .Name ,
243
243
utils .RayNodeTypeLabelKey : string (rayv1 .WorkerNode ),
244
244
}); err != nil {
245
245
return ctrl.Result {RequeueAfter : DefaultRequeueDuration }, err
246
246
}
247
- if numDeletedHeads > 0 {
247
+ if len ( headPods . Items ) > 0 {
248
248
logger .Info (fmt .Sprintf (
249
249
"Wait for the head Pod %s to be terminated before initiating the Redis cleanup process. " +
250
250
"The storage namespace %s in Redis cannot be fully deleted if the GCS process on the head Pod is still writing to it." ,
@@ -632,7 +632,7 @@ func (r *RayClusterReconciler) reconcilePods(ctx context.Context, instance *rayv
632
632
// if RayCluster is suspended, delete all pods and skip reconcile
633
633
if instance .Spec .Suspend != nil && * instance .Spec .Suspend {
634
634
clusterLabel := client.MatchingLabels {utils .RayClusterLabelKey : instance .Name }
635
- if _ , _ , err := r .deleteAllPods (ctx , instance .Namespace , clusterLabel ); err != nil {
635
+ if _ , err := r .deleteAllPods (ctx , instance .Namespace , clusterLabel ); err != nil {
636
636
return err
637
637
}
638
638
0 commit comments