-
Notifications
You must be signed in to change notification settings - Fork 665
[Feature][RayCluster]: Implement the HeadReady condition #2261
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
Changes from 18 commits
6b12c3f
b1c1a7e
0482ae2
0ee738c
8cbb04a
95ebeda
c90a5ef
44c545f
fe6c653
24df0bd
c02b4ff
ffa4f43
a497a41
5221359
3f059e7
583740c
e6e4a1b
94cf0f2
71e2340
8fe0751
01e90f6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1201,6 +1201,26 @@ func (r *RayClusterReconciler) calculateStatus(ctx context.Context, instance *ra | |
| newInstance.Status.State = rayv1.Ready | ||
| } | ||
|
|
||
| // Check if the head node is running and ready by checking the head pod's status. | ||
| if features.Enabled(features.RayClusterStatusConditions) { | ||
| headPod, err := common.GetRayClusterHeadPod(ctx, r, newInstance) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's possible for
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cc @rueian maybe we can return a non-nil error when there is no head Pod exists? I found that we always return a non-nil error. headPod, err := common.GetRayClusterHeadPod(ctx, r, newInstance)
if headPod == nil {
// return an error
} |
||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| // GetRayClusterHeadPod can return nil, nil when pod is not found, we handle it separately. | ||
| if headPod == nil { | ||
| meta.SetStatusCondition(&newInstance.Status.Conditions, metav1.Condition{ | ||
| Type: string(rayv1.HeadPodReady), | ||
| Status: metav1.ConditionFalse, | ||
| Reason: "HeadPodNotFound", | ||
| Message: "Head Pod not found", | ||
| }) | ||
| } else { | ||
| replicaHeadPodReadyCondition := utils.FindPodReadyCondition(headPod, rayv1.HeadPodReady) | ||
| meta.SetStatusCondition(&newInstance.Status.Conditions, replicaHeadPodReadyCondition) | ||
| } | ||
| } | ||
|
|
||
| if newInstance.Spec.Suspend != nil && *newInstance.Spec.Suspend && len(runtimePods.Items) == 0 { | ||
| newInstance.Status.State = rayv1.Suspended | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -25,6 +25,7 @@ import ( | |||||||||||||||||||
| ctrl "sigs.k8s.io/controller-runtime" | ||||||||||||||||||||
|
|
||||||||||||||||||||
| rayv1 "github.com/ray-project/kuberay/ray-operator/apis/ray/v1" | ||||||||||||||||||||
| v1 "github.com/ray-project/kuberay/ray-operator/apis/ray/v1" | ||||||||||||||||||||
cchen777 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||||||||
| ) | ||||||||||||||||||||
|
|
||||||||||||||||||||
| const ( | ||||||||||||||||||||
|
|
@@ -71,6 +72,35 @@ func IsCreated(pod *corev1.Pod) bool { | |||||||||||||||||||
| return pod.Status.Phase != "" | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| func FindPodReadyCondition(pod *corev1.Pod, condType rayv1.RayClusterConditionType) metav1.Condition { | ||||||||||||||||||||
| replicaPodReadyCondition := metav1.Condition{ | ||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it possible for
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes you are right, i update the logic here to have an initial Condition kuberay/ray-operator/controllers/ray/utils/util.go Lines 75 to 79 in 01e90f6
plus this logic kuberay/ray-operator/controllers/ray/utils/util.go Lines 95 to 98 in 01e90f6
to prevent empty reason sneak into later |
||||||||||||||||||||
| Type: string(condType), | ||||||||||||||||||||
| Status: metav1.ConditionFalse, | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| for _, cond := range pod.Status.Conditions { | ||||||||||||||||||||
| if cond.Type == corev1.PodReady { | ||||||||||||||||||||
|
||||||||||||||||||||
| if cond.Status == corev1.ConditionTrue { | ||||||||||||||||||||
| replicaPodReadyCondition = metav1.Condition{ | ||||||||||||||||||||
| Type: string(condType), | ||||||||||||||||||||
| Status: metav1.ConditionTrue, | ||||||||||||||||||||
| Reason: v1.PodRunningAndReady, // metav1.Condition.Reason requires a non-empty value | ||||||||||||||||||||
| Message: cond.Message, | ||||||||||||||||||||
| } | ||||||||||||||||||||
| } else { | ||||||||||||||||||||
| replicaPodReadyCondition = metav1.Condition{ | ||||||||||||||||||||
| Type: string(condType), | ||||||||||||||||||||
| Status: metav1.ConditionFalse, | ||||||||||||||||||||
| Reason: cond.Reason, // PodReady condition comes with a reason when it's not ready, e.g. ContainersNotReady | ||||||||||||||||||||
| Message: cond.Message, | ||||||||||||||||||||
| } | ||||||||||||||||||||
| break | ||||||||||||||||||||
cchen777 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||||||||
| } | ||||||||||||||||||||
| } | ||||||||||||||||||||
| } | ||||||||||||||||||||
| return replicaPodReadyCondition | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| // IsRunningAndReady returns true if pod is in the PodRunning Phase, if it has a condition of PodReady. | ||||||||||||||||||||
| func IsRunningAndReady(pod *corev1.Pod) bool { | ||||||||||||||||||||
| if pod.Status.Phase != corev1.PodRunning { | ||||||||||||||||||||
|
|
||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.