-
Notifications
You must be signed in to change notification settings - Fork 42
[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
base: slice-main
Are you sure you want to change the base?
[slice] Don't create Slice if Workload doesn't have Topology Assignment. #515
Conversation
exists := slices.Contains(slice.Spec.NodeSelector[TPUReservationSubblockLabel], v) | ||
if !exists { | ||
slice.Spec.NodeSelector[TPUReservationSubblockLabel] = append(slice.Spec.NodeSelector[TPUReservationSubblockLabel], v) | ||
if psa.TopologyAssignment != nil { |
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.
It can be possible that Workload have PodSetAssignments but doesn't have TopologyAssignment.
if slice.Spec.NodeSelector == nil { | ||
slice.Spec.NodeSelector = make(map[string][]string) | ||
} | ||
if slice.Spec.NodeSelector[TPUReservationSubblockLabel] == nil { | ||
slice.Spec.NodeSelector[TPUReservationSubblockLabel] = []string{} | ||
} |
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.
Can we move this logic outside of the loop?
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.
No, because psa.TopologyAssignment
can be nil, and we can only check that inside the loop.
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.
Or you mean to check it before execute newSlice?
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.
Added method hasTopologyAssignment to check it before adding finalizer.
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.
Can we add a UT for a case where TopologyAssignment arrives after some delay?
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.
We have this test:
xpk/slice/internal/controller/workload_controller_test.go
Lines 103 to 153 in 3975e28
"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(), | |
}, | |
}, |
3975e28
to
9fba2b4
Compare
9fba2b4
to
f970553
Compare
b5ba2f0
to
aeeaeef
Compare
@PBundyra PTAL |
Fixes / Features