Skip to content
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

Check existing pods for suspended RayCluster before calling DeleteCollection #1745

Merged
merged 1 commit into from
Dec 13, 2023

Conversation

andrewsykim
Copy link
Contributor

Why are these changes needed?

Follow-up to #1711 & #1741.

After #1741, we always run the reconcile loop for suspended RayCluster, regardless of it's state. This means that for suspended clusters we will always call DeleteCollection and record an event.

This PR makes a small optimization to check existing pods before calling DeleteCollection. This should not be susceptible to the same bug fixed in #1741 since we are not checking cluster state, but rather checking informer cache for existing pods.

Related issue number

#1667

Checks

  • I've made sure the tests are passing.
  • Testing Strategy
    • Unit tests
    • Manual tests
    • This PR is not tested :(

…lection

Signed-off-by: Andrew Sy Kim <andrewsy@google.com>
Copy link
Contributor Author

@andrewsykim andrewsykim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -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 {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not super familiar with controller-runtime's client, but I'm guessing this is a list from the informer cache, which is better than always calling DeleteCollection below.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessing this is a list from the informer cache

Yes, in KubeRay's setup, the List operation reads from the informer cache.

Copy link
Member

@kevin85421 kevin85421 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kevin85421 kevin85421 merged commit bf3fd63 into ray-project:master Dec 13, 2023
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants