@@ -110,18 +110,20 @@ func (r *WorkloadReconciler) newSlice(wl *kueue.Workload) (*v1alpha1.Slice, erro
110
110
111
111
if wl .Status .Admission != nil && wl .Status .Admission .PodSetAssignments != nil {
112
112
for _ , psa := range wl .Status .Admission .PodSetAssignments {
113
- for _ , domain := range psa .TopologyAssignment .Domains {
114
- if slice .Spec .NodeSelector == nil {
115
- slice .Spec .NodeSelector = make (map [string ][]string )
116
- }
117
- if slice .Spec .NodeSelector [TPUReservationSubblockLabel ] == nil {
118
- slice .Spec .NodeSelector [TPUReservationSubblockLabel ] = []string {}
119
- }
120
- // make sure there are no duplicates in the nodeSelector
121
- for _ , v := range domain .Values {
122
- exists := slices .Contains (slice .Spec .NodeSelector [TPUReservationSubblockLabel ], v )
123
- if ! exists {
124
- slice .Spec .NodeSelector [TPUReservationSubblockLabel ] = append (slice .Spec .NodeSelector [TPUReservationSubblockLabel ], v )
113
+ if psa .TopologyAssignment != nil {
114
+ for _ , domain := range psa .TopologyAssignment .Domains {
115
+ if slice .Spec .NodeSelector == nil {
116
+ slice .Spec .NodeSelector = make (map [string ][]string )
117
+ }
118
+ if slice .Spec .NodeSelector [TPUReservationSubblockLabel ] == nil {
119
+ slice .Spec .NodeSelector [TPUReservationSubblockLabel ] = []string {}
120
+ }
121
+ // make sure there are no duplicates in the nodeSelector
122
+ for _ , v := range domain .Values {
123
+ exists := slices .Contains (slice .Spec .NodeSelector [TPUReservationSubblockLabel ], v )
124
+ if ! exists {
125
+ slice .Spec .NodeSelector [TPUReservationSubblockLabel ] = append (slice .Spec .NodeSelector [TPUReservationSubblockLabel ], v )
126
+ }
125
127
}
126
128
}
127
129
}
@@ -147,6 +149,13 @@ func (r *WorkloadReconciler) createSliceIfNotExist(ctx context.Context, wl *kueu
147
149
return err
148
150
}
149
151
152
+ // We should wait for TopologyAssignments.
153
+ if len (slice .Spec .NodeSelector ) == 0 {
154
+ log := ctrl .LoggerFrom (ctx )
155
+ log .V (2 ).Info ("Workload does not have TopologyAssignments. Skipping Slice creation for now." )
156
+ return nil
157
+ }
158
+
150
159
return r .client .Create (ctx , slice )
151
160
}
152
161
0 commit comments