-
Notifications
You must be signed in to change notification settings - Fork 410
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add finalizer to worker pods to ensure min replica #2041
base: master
Are you sure you want to change the base?
Add finalizer to worker pods to ensure min replica #2041
Conversation
} | ||
|
||
} | ||
continue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if !controllerutil.ContainsFinalizer(&workerPod, utils.WorkerDeletionFinalizer) {
continue
}
if int32(len(workerPods.Items)) <= *worker.MinReplicas {
// If the number of worker Pods is less than or equal to the minimum number of replicas, we should not delete the
Pod.
logger.Info("reconcilePods", "worker Pod", workerPod.Name, "shouldDelete", false, "reason", "Number of worker Pods is less than or equal to the minimum number of replicas")
} else {
controllerutil.RemoveFinalizer(&workerPod, utils.WorkerDeletionFinalizer)
if err := r.Update(ctx, &workerPod); err != nil {
return err
}
}
@@ -759,6 +759,21 @@ func (r *RayClusterReconciler) reconcilePods(ctx context.Context, instance *rayv | |||
deleted := struct{}{} | |||
numDeletedUnhealthyWorkerPods := 0 | |||
for _, workerPod := range workerPods.Items { | |||
if workerPod.ObjectMeta.DeletionTimestamp != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure how much this check helps.
Even with a finalizer configured, if a pod has been deleted with a deletion timestamp it is already terminating. We will keep the Pod object around but the worker will not actually be available.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's true. Would admission webhook be better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we are trying to avoid admission webhooks as much as possible. @kevin85421 thoughts?
Why are these changes needed?
Currently all worker pods can be deleted without protection, regardless of minReplica. This change adds a protection of minReplica using finalizer.
Related issue number
Fix #1740
Checks