-
Notifications
You must be signed in to change notification settings - Fork 251
fix(binder): preserve reservations during bind cache lag #2049
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
Closed
+91
−7
Closed
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 |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| kind: Fixed | ||
| body: |- | ||
| Preserve reservation pods during BindRequest cache lag |
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 |
|---|---|---|
|
|
@@ -226,26 +226,66 @@ func (rsc *service) syncForPods(ctx context.Context, pods []*v1.Pod, gpuGroupToS | |
| return nil | ||
| } | ||
|
|
||
| // hasActiveBindRequestsForGpuGroup checks if any non-terminal BindRequests reference | ||
| // the given GPU group. This prevents premature reservation pod deletion when the | ||
| // informer cache has not yet propagated GPU group labels on recently-bound fraction pods. | ||
| // hasActiveBindRequestsForGpuGroup checks if BindRequests still protect the GPU group. | ||
| // A succeeded BindRequest also protects the reservation while its pod is still alive: | ||
| // the pod label can lag behind the BindRequest status in the controller cache. | ||
| func (rsc *service) hasActiveBindRequestsForGpuGroup(ctx context.Context, gpuGroup string) (bool, error) { | ||
| bindRequestList := &schedulingv1alpha2.BindRequestList{} | ||
| if err := rsc.kubeClient.List(ctx, bindRequestList); err != nil { | ||
| return false, fmt.Errorf("failed to list BindRequests: %w", err) | ||
| } | ||
|
|
||
| for _, br := range bindRequestList.Items { | ||
| if br.Status.Phase == schedulingv1alpha2.BindRequestPhaseSucceeded || | ||
| br.Status.Phase == schedulingv1alpha2.BindRequestPhaseFailed { | ||
| if !slices.Contains(br.Spec.SelectedGPUGroups, gpuGroup) { | ||
| continue | ||
| } | ||
| if slices.Contains(br.Spec.SelectedGPUGroups, gpuGroup) { | ||
| return true, nil | ||
|
|
||
| if br.Status.Phase == schedulingv1alpha2.BindRequestPhaseFailed { | ||
| continue | ||
| } | ||
|
|
||
| if br.Status.Phase == schedulingv1alpha2.BindRequestPhaseSucceeded { | ||
| hasLivePod, err := rsc.hasLivePodForBindRequest(ctx, &br) | ||
| if err != nil { | ||
| return false, err | ||
| } | ||
| if hasLivePod { | ||
| return true, nil | ||
| } | ||
| continue | ||
| } | ||
|
|
||
| return true, nil | ||
| } | ||
| return false, nil | ||
| } | ||
|
|
||
| func (rsc *service) hasLivePodForBindRequest(ctx context.Context, bindRequest *schedulingv1alpha2.BindRequest) (bool, error) { | ||
| pod := &v1.Pod{} | ||
| err := rsc.kubeClient.Get(ctx, client.ObjectKey{ | ||
| Namespace: bindRequest.Namespace, | ||
| Name: bindRequest.Spec.PodName, | ||
| }, pod) | ||
| if apierrors.IsNotFound(err) { | ||
| return false, nil | ||
| } | ||
| if err != nil { | ||
| return false, fmt.Errorf("failed to get pod for BindRequest <%s/%s>: %w", | ||
| bindRequest.Namespace, bindRequest.Name, err) | ||
| } | ||
|
|
||
| if slices.Contains([]v1.PodPhase{v1.PodSucceeded, v1.PodFailed}, pod.Status.Phase) { | ||
| return false, nil | ||
| } | ||
|
|
||
| for _, gpuGroup := range bindRequest.Spec.SelectedGPUGroups { | ||
| if slices.Contains(resources.GetGpuGroups(pod), gpuGroup) { | ||
|
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. What is the effect of this loop? We return true afterwards anyway, right? |
||
| return true, nil | ||
| } | ||
| } | ||
|
|
||
| return true, nil | ||
| } | ||
| func (rsc *service) ReserveGpuDevice(ctx context.Context, pod *v1.Pod, nodeName string, gpuGroup string) (string, error) { | ||
| logger := log.FromContext(ctx) | ||
|
|
||
|
|
||
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.
Consider also matching the UID of the pod (against the BindRequests's OwnerReference) since a pod can be recreated with the same name.