@@ -205,10 +205,27 @@ func buildOBClusterTopologyResp(ctx context.Context, obcluster *v1alpha1.OBClust
205
205
zoneAffinity := obzone .Spec .Topology .Affinity
206
206
switch {
207
207
case zoneAffinity .NodeAffinity != nil :
208
- for _ , term := range zoneAffinity .NodeAffinity .RequiredDuringSchedulingIgnoredDuringExecution .NodeSelectorTerms {
209
- for _ , req := range term .MatchExpressions {
208
+ zn := zoneAffinity .NodeAffinity
209
+ if zn .RequiredDuringSchedulingIgnoredDuringExecution != nil {
210
+ for _ , term := range zn .RequiredDuringSchedulingIgnoredDuringExecution .NodeSelectorTerms {
211
+ for _ , req := range term .MatchExpressions {
212
+ affinities = append (affinities , modelcommon.AffinitySpec {
213
+ Type : modelcommon .NodeAffinityType ,
214
+ SelectorExpression : modelcommon.SelectorExpression {
215
+ Key : req .Key ,
216
+ Operator : string (req .Operator ),
217
+ Values : req .Values ,
218
+ },
219
+ })
220
+ }
221
+ }
222
+ }
223
+ for _ , term := range zn .PreferredDuringSchedulingIgnoredDuringExecution {
224
+ for _ , req := range term .Preference .MatchExpressions {
210
225
affinities = append (affinities , modelcommon.AffinitySpec {
211
- Type : modelcommon .NodeAffinityType ,
226
+ Type : modelcommon .NodeAffinityType ,
227
+ Weight : term .Weight ,
228
+ Preferred : true ,
212
229
SelectorExpression : modelcommon.SelectorExpression {
213
230
Key : req .Key ,
214
231
Operator : string (req .Operator ),
@@ -218,7 +235,8 @@ func buildOBClusterTopologyResp(ctx context.Context, obcluster *v1alpha1.OBClust
218
235
}
219
236
}
220
237
case zoneAffinity .PodAffinity != nil :
221
- for _ , term := range zoneAffinity .PodAffinity .RequiredDuringSchedulingIgnoredDuringExecution {
238
+ zp := zoneAffinity .PodAffinity
239
+ for _ , term := range zp .RequiredDuringSchedulingIgnoredDuringExecution {
222
240
for _ , req := range term .LabelSelector .MatchExpressions {
223
241
affinities = append (affinities , modelcommon.AffinitySpec {
224
242
Type : modelcommon .PodAffinityType ,
@@ -230,8 +248,23 @@ func buildOBClusterTopologyResp(ctx context.Context, obcluster *v1alpha1.OBClust
230
248
})
231
249
}
232
250
}
251
+ for _ , term := range zp .PreferredDuringSchedulingIgnoredDuringExecution {
252
+ for _ , req := range term .PodAffinityTerm .LabelSelector .MatchExpressions {
253
+ affinities = append (affinities , modelcommon.AffinitySpec {
254
+ Type : modelcommon .PodAffinityType ,
255
+ Weight : term .Weight ,
256
+ Preferred : true ,
257
+ SelectorExpression : modelcommon.SelectorExpression {
258
+ Key : req .Key ,
259
+ Operator : string (req .Operator ),
260
+ Values : req .Values ,
261
+ },
262
+ })
263
+ }
264
+ }
233
265
case zoneAffinity .PodAntiAffinity != nil :
234
- for _ , term := range zoneAffinity .PodAntiAffinity .RequiredDuringSchedulingIgnoredDuringExecution {
266
+ zpa := zoneAffinity .PodAntiAffinity
267
+ for _ , term := range zpa .RequiredDuringSchedulingIgnoredDuringExecution {
235
268
for _ , req := range term .LabelSelector .MatchExpressions {
236
269
affinities = append (affinities , modelcommon.AffinitySpec {
237
270
Type : modelcommon .PodAntiAffinityType ,
@@ -243,14 +276,33 @@ func buildOBClusterTopologyResp(ctx context.Context, obcluster *v1alpha1.OBClust
243
276
})
244
277
}
245
278
}
279
+ for _ , term := range zpa .PreferredDuringSchedulingIgnoredDuringExecution {
280
+ for _ , req := range term .PodAffinityTerm .LabelSelector .MatchExpressions {
281
+ affinities = append (affinities , modelcommon.AffinitySpec {
282
+ Type : modelcommon .PodAntiAffinityType ,
283
+ Weight : term .Weight ,
284
+ Preferred : true ,
285
+ SelectorExpression : modelcommon.SelectorExpression {
286
+ Key : req .Key ,
287
+ Operator : string (req .Operator ),
288
+ Values : req .Values ,
289
+ },
290
+ })
291
+ }
292
+ }
246
293
}
247
294
}
248
295
249
- tolerations := make ([]modelcommon.KVPair , 0 )
296
+ tolerations := make ([]modelcommon.TolerationSpec , 0 )
250
297
for _ , toleration := range obzone .Spec .Topology .Tolerations {
251
- tolerations = append (tolerations , modelcommon.KVPair {
252
- Key : toleration .Key ,
253
- Value : toleration .Value ,
298
+ tolerations = append (tolerations , modelcommon.TolerationSpec {
299
+ KVPair : modelcommon.KVPair {
300
+ Key : toleration .Key ,
301
+ Value : toleration .Value ,
302
+ },
303
+ Operator : string (toleration .Operator ),
304
+ Effect : string (toleration .Effect ),
305
+ TolerationSeconds : toleration .TolerationSeconds ,
254
306
})
255
307
}
256
308
respZone := response.OBZone {
0 commit comments