Skip to content

[slice] Don't create Slice if Workload doesn't have Topology Assignment. #515

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
wants to merge 2 commits into
base: slice-main
Choose a base branch
from

Conversation

mbobrovskyi
Copy link
Collaborator

Fixes / Features

  • Don't create Slice if Workload doesn't have Topology Assignment.

@mbobrovskyi
Copy link
Collaborator Author

@PBundyra @IrvingMg PTAL

exists := slices.Contains(slice.Spec.NodeSelector[TPUReservationSubblockLabel], v)
if !exists {
slice.Spec.NodeSelector[TPUReservationSubblockLabel] = append(slice.Spec.NodeSelector[TPUReservationSubblockLabel], v)
if psa.TopologyAssignment != nil {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It can be possible that Workload have PodSetAssignments but doesn't have TopologyAssignment.

@mbobrovskyi mbobrovskyi changed the title Don't create Slice if Workload doesn't have Topology Assignment. [slice] Don't create Slice if Workload doesn't have Topology Assignment. Jun 30, 2025
Comment on lines +115 to +135
if slice.Spec.NodeSelector == nil {
slice.Spec.NodeSelector = make(map[string][]string)
}
if slice.Spec.NodeSelector[TPUReservationSubblockLabel] == nil {
slice.Spec.NodeSelector[TPUReservationSubblockLabel] = []string{}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we move this logic outside of the loop?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No, because psa.TopologyAssignment can be nil, and we can only check that inside the loop.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Or you mean to check it before execute newSlice?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added method hasTopologyAssignment to check it before adding finalizer.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we add a UT for a case where TopologyAssignment arrives after some delay?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We have this test:

"parse TAS Assignment to populate NodeSelector in Slice": {
request: baseRequest,
workload: baseWorkloadWrapper.Clone().
UID(types.UID(baseWorkloadName)).
PodSetAssignments(utiltesting.MakePodSetAssignment("psa1").
TopologyAssignment(nil, []kueue.TopologyDomainAssignment{
{
Values: []string{"domain1", "domain2"},
Count: 2,
},
}).Obj(),
utiltesting.MakePodSetAssignment("psa2").
TopologyAssignment(nil, []kueue.TopologyDomainAssignment{
{
Values: []string{"domain2", "domain3"},
Count: 2,
},
}).
Obj(),
).Obj(),
wantWorkloads: []kueue.Workload{
*baseWorkloadWrapper.Clone().
UID(types.UID(baseWorkloadName)).
PodSetAssignments(utiltesting.MakePodSetAssignment("psa1").
TopologyAssignment(nil, []kueue.TopologyDomainAssignment{
{
Values: []string{"domain1", "domain2"},
Count: 2,
},
}).Obj(),
utiltesting.MakePodSetAssignment("psa2").
TopologyAssignment(nil, []kueue.TopologyDomainAssignment{
{
Values: []string{"domain2", "domain3"},
Count: 2,
},
}).
Obj(),
).
Finalizers(CleanupSliceFinalizerName).
Obj(),
},
wantSlices: []v1alpha1.Slice{
*baseSliceWrapper.Clone().
ControllerReference(kueue.GroupVersion.WithKind("Workload"), baseWorkloadName, baseWorkloadName).
NodeSelector(map[string][]string{
TPUReservationSubblockLabel: {"domain1", "domain2", "domain3"},
}).
Obj(),
},
},

@mbobrovskyi mbobrovskyi force-pushed the slice/do-not-create-slice-if-workload-does-not-have-topology-assigmenemnt branch from 3975e28 to 9fba2b4 Compare July 1, 2025 14:33
@mbobrovskyi mbobrovskyi requested a review from PBundyra July 1, 2025 14:35
@mbobrovskyi mbobrovskyi force-pushed the slice/do-not-create-slice-if-workload-does-not-have-topology-assigmenemnt branch from 9fba2b4 to f970553 Compare July 1, 2025 16:36
@mbobrovskyi mbobrovskyi force-pushed the slice/do-not-create-slice-if-workload-does-not-have-topology-assigmenemnt branch from b5ba2f0 to aeeaeef Compare July 3, 2025 09:01
@mbobrovskyi
Copy link
Collaborator Author

@PBundyra PTAL

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.

3 participants