-
Notifications
You must be signed in to change notification settings - Fork 611
Account for KubeRay Redis cleanup resources #11260
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
Open
nerdeveloper
wants to merge
1
commit into
kubernetes-sigs:main
Choose a base branch
from
nerdeveloper:fix-ray-gcs-cleanup-quota-10946
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,10 +20,14 @@ import ( | |
| "context" | ||
| "encoding/json" | ||
| "fmt" | ||
| "maps" | ||
| "strconv" | ||
|
|
||
| rayv1 "github.com/ray-project/kuberay/ray-operator/apis/ray/v1" | ||
| rayutils "github.com/ray-project/kuberay/ray-operator/controllers/ray/utils" | ||
| corev1 "k8s.io/api/core/v1" | ||
| apierrors "k8s.io/apimachinery/pkg/api/errors" | ||
| "k8s.io/apimachinery/pkg/api/resource" | ||
| metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
| "k8s.io/apimachinery/pkg/types" | ||
| "k8s.io/apimachinery/pkg/util/validation/field" | ||
|
|
@@ -40,6 +44,9 @@ import ( | |
| ) | ||
|
|
||
| const ( | ||
| redisCleanupPodSetName = kueue.PodSetReference(rayv1.RedisCleanupNode) | ||
| maxRayClusterPodSets = 8 | ||
|
|
||
| // RayClusterPodsetReplicaSizesAnnotation is set on the job when autoscaling causes | ||
| // PodSet replica sizes to differ from the original spec. The value is a JSON | ||
| // array compatible with []kueue.PodSet, containing only the changed PodSets. | ||
|
|
@@ -96,9 +103,66 @@ func BuildPodSets(rayClusterSpec *rayv1.RayClusterSpec) ([]kueue.PodSet, error) | |
| podSets = append(podSets, workerPodSet) | ||
| } | ||
|
|
||
| if hasGCSFaultTolerance(rayClusterSpec) { | ||
| podSets = append(podSets, buildRedisCleanupPodSet(rayClusterSpec)) | ||
| } | ||
|
|
||
| return podSets, nil | ||
| } | ||
|
|
||
| func buildRedisCleanupPodSet(rayClusterSpec *rayv1.RayClusterSpec) kueue.PodSet { | ||
| template := *rayClusterSpec.HeadGroupSpec.Template.DeepCopy() | ||
| template.Labels = maps.Clone(template.Labels) | ||
| if template.Labels == nil { | ||
| template.Labels = make(map[string]string, 1) | ||
| } | ||
| template.Labels[rayutils.RayNodeTypeLabelKey] = string(rayv1.RedisCleanupNode) | ||
| if len(template.Spec.Containers) > 0 { | ||
| template.Spec.Containers = []corev1.Container{*template.Spec.Containers[rayutils.RayContainerIndex].DeepCopy()} | ||
| template.Spec.Containers[rayutils.RayContainerIndex].Resources = redisCleanupResourceRequirements() | ||
| } | ||
| template.Spec.RestartPolicy = corev1.RestartPolicyNever | ||
|
|
||
| return kueue.PodSet{ | ||
| Name: redisCleanupPodSetName, | ||
| Template: template, | ||
| Count: 1, | ||
| } | ||
| } | ||
|
|
||
| func redisCleanupResourceRequirements() corev1.ResourceRequirements { | ||
| return corev1.ResourceRequirements{ | ||
| Limits: corev1.ResourceList{ | ||
| corev1.ResourceCPU: resource.MustParse("200m"), | ||
| corev1.ResourceMemory: resource.MustParse("256Mi"), | ||
| }, | ||
| Requests: corev1.ResourceList{ | ||
| corev1.ResourceCPU: resource.MustParse("200m"), | ||
| corev1.ResourceMemory: resource.MustParse("256Mi"), | ||
| }, | ||
| } | ||
| } | ||
|
|
||
| func hasGCSFaultTolerance(rayClusterSpec *rayv1.RayClusterSpec) bool { | ||
| return rayClusterSpec.GcsFaultToleranceOptions != nil | ||
|
Contributor
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. Could you check with the KubeRay code is this is a sufficient check? I remember that there was also a knob at the kuberay deployment that would be the global enabler, which is disabled would make this check irrelevant. |
||
| } | ||
|
|
||
| func ExpectedPodSetsCount(rayClusterSpec *rayv1.RayClusterSpec) int { | ||
| count := len(rayClusterSpec.WorkerGroupSpecs) + 1 | ||
| if hasGCSFaultTolerance(rayClusterSpec) { | ||
| count++ | ||
| } | ||
| return count | ||
| } | ||
|
|
||
| func maxWorkerGroupsForSpec(rayClusterSpec *rayv1.RayClusterSpec) int { | ||
| maxWorkerGroups := maxRayClusterPodSets - 1 | ||
| if hasGCSFaultTolerance(rayClusterSpec) { | ||
| maxWorkerGroups-- | ||
| } | ||
| return maxWorkerGroups | ||
| } | ||
|
|
||
| func UpdatePodSets(ctx context.Context, podSets []kueue.PodSet, c client.Client, object client.Object, enableInTreeAutoscaling *bool, rayClusterName string) ([]kueue.PodSet, error) { | ||
| log := ctrl.LoggerFrom(ctx) | ||
|
|
||
|
|
@@ -216,9 +280,9 @@ func ValidateCreate(object client.Object, rayClusterSpec *rayv1.RayClusterSpec, | |
| ) | ||
| } | ||
|
|
||
| // Should limit the worker count to 8 - 1 (max podSets num - cluster head) | ||
| if len(rayClusterSpec.WorkerGroupSpecs) > 7 { | ||
| allErrors = append(allErrors, field.TooMany(rayClusterSpecPath.Child("workerGroupSpecs"), len(rayClusterSpec.WorkerGroupSpecs), 7)) | ||
| // Should limit the worker count to the maximum PodSet count, minus the head and optional Redis cleanup PodSets. | ||
| if maxWorkerGroups := maxWorkerGroupsForSpec(rayClusterSpec); len(rayClusterSpec.WorkerGroupSpecs) > maxWorkerGroups { | ||
| allErrors = append(allErrors, field.TooMany(rayClusterSpecPath.Child("workerGroupSpecs"), len(rayClusterSpec.WorkerGroupSpecs), maxWorkerGroups)) | ||
| } | ||
|
|
||
| // None of the workerGroups should be named "head" | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Since this is a delicate change let's introduce a feature gate as a bailout option, say
KubeRayAccountForRedisCleanupwhich is Beta, and add a comment o GA in 0.21 in Kueue.