19
19
</el-col >
20
20
</el-row >
21
21
<el-row :gutter =" 20" >
22
- <el-col :span =" 12" >
23
- <el-form-item label =" Namespace" >
24
- <ko-form-item itemType =" select2" v-model =" item.namespaces" multiple :selections =" namespace_list" />
25
- </el-form-item >
26
- </el-col >
27
22
<el-col :span =" 12" v-if =" item.priority === 'Preferred'" >
28
23
<el-form-item :label =" $t('business.workload.weight')" >
29
24
<ko-form-item itemType =" number" v-model =" item.weight" />
@@ -151,7 +146,6 @@ export default {
151
146
var item = {
152
147
type: " Affinity" ,
153
148
priority: " Preferred" ,
154
- namespaces: " " ,
155
149
weight: 1 ,
156
150
rules: [],
157
151
labelRules: [],
@@ -208,7 +202,6 @@ export default {
208
202
},
209
203
210
204
valueTrans (type , priority , s ) {
211
- let namespaces = s .namespaces || " "
212
205
let rules = []
213
206
if (s .labelSelector .matchExpressions ) {
214
207
for (const express of s .labelSelector .matchExpressions ) {
@@ -231,7 +224,6 @@ export default {
231
224
type: type,
232
225
priority: priority,
233
226
weight: s .weight || null ,
234
- namespaces: namespaces || " " ,
235
227
rules: rules,
236
228
labelRules: labelRules,
237
229
topologyKey: topologyKey,
@@ -263,8 +255,7 @@ export default {
263
255
if (this .podSchedulings .length !== 0 ) {
264
256
for (const pS of this .podSchedulings ) {
265
257
let itemAdd = {}
266
- itemAdd .namespaces = (pS .namespaces && pS .namespaces .length !== 0 ) ? pS .namespaces : undefined
267
- itemAdd .topologyKey = pS .topologyKey || undefined
258
+ const itemTopologyKey = pS .topologyKey || undefined
268
259
const matchs = this .getMatchExpress (pS .rules )
269
260
const labelMatchs = this .getMatchLabels (pS .labelRules )
270
261
switch (pS .type + " +" + pS .priority ) {
@@ -274,15 +265,16 @@ export default {
274
265
}
275
266
parentFrom .affinity .podAffinity .requiredDuringSchedulingIgnoredDuringExecution = []
276
267
itemAdd .labelSelector = { matchExpressions: matchs, matchLabels: labelMatchs }
268
+ itemAdd .topologyKey = itemTopologyKey
277
269
parentFrom .affinity .podAffinity .requiredDuringSchedulingIgnoredDuringExecution .push (itemAdd)
278
270
break
279
271
case " Affinity+Preferred" :
280
272
if (! parentFrom .affinity .podAffinity ) {
281
273
parentFrom .affinity .podAffinity = {}
282
274
}
283
275
parentFrom .affinity .podAffinity .preferredDuringSchedulingIgnoredDuringExecution = []
284
- itemAdd .podAffinityTerm = { labelSelector: { matchExpressions: matchs, matchLabels: labelMatchs } }
285
- itemAdd .weight = pS .weight
276
+ itemAdd .podAffinityTerm = { topologyKey : itemTopologyKey, labelSelector: { matchExpressions: matchs, matchLabels: labelMatchs } }
277
+ itemAdd .weight = pS .weight || 1
286
278
parentFrom .affinity .podAffinity .preferredDuringSchedulingIgnoredDuringExecution .push (itemAdd)
287
279
break
288
280
case " Anti-Affinity+Required" :
@@ -291,41 +283,47 @@ export default {
291
283
}
292
284
parentFrom .affinity .podAntiAffinity .requiredDuringSchedulingIgnoredDuringExecution = []
293
285
itemAdd .labelSelector = { matchExpressions: matchs, matchLabels: labelMatchs }
286
+ itemAdd .topologyKey = itemTopologyKey
294
287
parentFrom .affinity .podAntiAffinity .requiredDuringSchedulingIgnoredDuringExecution .push (itemAdd)
295
288
break
296
289
case " Anti-Affinity+Preferred" :
297
290
if (! parentFrom .affinity .podAntiAffinity ) {
298
291
parentFrom .affinity .podAntiAffinity = {}
299
292
}
300
293
parentFrom .affinity .podAntiAffinity .preferredDuringSchedulingIgnoredDuringExecution = []
301
- itemAdd .podAffinityTerm = { labelSelector: { matchExpressions: matchs, matchLabels: labelMatchs } }
302
- itemAdd .weight = pS .weight
294
+ itemAdd .podAffinityTerm = { topologyKey : itemTopologyKey, labelSelector: { matchExpressions: matchs, matchLabels: labelMatchs } }
295
+ itemAdd .weight = pS .weight || 1
303
296
parentFrom .affinity .podAntiAffinity .preferredDuringSchedulingIgnoredDuringExecution .push (itemAdd)
304
297
break
305
298
}
306
299
}
307
300
}
308
- parentFrom .nodeAffinity = {}
309
301
if (this .nodeSchedulings .length !== 0 ) {
310
302
for (const nS of this .nodeSchedulings ) {
311
303
const matchs = this .getMatchExpress (nS .rules )
312
304
const fields = this .getMatchExpress (nS .fields )
313
305
let itemAdd = {}
314
306
switch (nS .priority ) {
315
307
case " Preferred" :
316
- parentFrom .nodeAffinity .preferredDuringSchedulingIgnoredDuringExecution = []
308
+ if (! parentFrom .affinity .nodeAffinity ) {
309
+ parentFrom .affinity .nodeAffinity = {}
310
+ }
311
+ parentFrom .affinity .nodeAffinity .preferredDuringSchedulingIgnoredDuringExecution = []
317
312
itemAdd .weight = nS .weight
318
313
itemAdd .preference = { matchExpressions: matchs, matchFields: fields }
319
- parentFrom .nodeAffinity .preferredDuringSchedulingIgnoredDuringExecution .push (itemAdd)
314
+ parentFrom .affinity . nodeAffinity .preferredDuringSchedulingIgnoredDuringExecution .push (itemAdd)
320
315
break
321
316
case " Required" :
322
- if (! parentFrom .nodeAffinity . requiredDuringSchedulingIgnoredDuringExecution ) {
323
- parentFrom .nodeAffinity . requiredDuringSchedulingIgnoredDuringExecution = {}
317
+ if (! parentFrom .affinity . nodeAffinity ) {
318
+ parentFrom .affinity . nodeAffinity = {}
324
319
}
325
- parentFrom .nodeAffinity .requiredDuringSchedulingIgnoredDuringExecution .nodeSelectorTerms = []
320
+ if (! parentFrom .affinity .nodeAffinity .requiredDuringSchedulingIgnoredDuringExecution ) {
321
+ parentFrom .affinity .nodeAffinity .requiredDuringSchedulingIgnoredDuringExecution = {}
322
+ }
323
+ parentFrom .affinity .nodeAffinity .requiredDuringSchedulingIgnoredDuringExecution .nodeSelectorTerms = []
326
324
itemAdd .matchExpressions = matchs
327
325
itemAdd .matchFields = fields
328
- parentFrom .nodeAffinity .requiredDuringSchedulingIgnoredDuringExecution .nodeSelectorTerms .push (itemAdd)
326
+ parentFrom .affinity . nodeAffinity .requiredDuringSchedulingIgnoredDuringExecution .nodeSelectorTerms .push (itemAdd)
329
327
break
330
328
}
331
329
}
@@ -369,47 +367,47 @@ export default {
369
367
}
370
368
}
371
369
}
372
- }
373
370
374
- if (this .podSchedulingParentObj .nodeAffinity ) {
375
- if (this .podSchedulingParentObj .nodeAffinity .requiredDuringSchedulingIgnoredDuringExecution ) {
376
- if (this .podSchedulingParentObj .nodeAffinity .requiredDuringSchedulingIgnoredDuringExecution .nodeSelectorTerms ) {
377
- const schedulings = this .podSchedulingParentObj .nodeAffinity .requiredDuringSchedulingIgnoredDuringExecution .nodeSelectorTerms
378
- for (const s of schedulings) {
379
- let rules = []
380
- if (s .matchExpressions ) {
381
- for (const express of s .matchExpressions ) {
382
- rules .push ({ key: express .key , operator: express .operator , value: express .values .join (" ," ) })
371
+ if (this .podSchedulingParentObj .affinity .nodeAffinity ) {
372
+ if (this .podSchedulingParentObj .affinity .nodeAffinity .requiredDuringSchedulingIgnoredDuringExecution ) {
373
+ if (this .podSchedulingParentObj .affinity .nodeAffinity .requiredDuringSchedulingIgnoredDuringExecution .nodeSelectorTerms ) {
374
+ const schedulings = this .podSchedulingParentObj .affinity .nodeAffinity .requiredDuringSchedulingIgnoredDuringExecution .nodeSelectorTerms
375
+ for (const s of schedulings) {
376
+ let rules = []
377
+ if (s .matchExpressions ) {
378
+ for (const express of s .matchExpressions ) {
379
+ rules .push ({ key: express .key , operator: express .operator , value: express .values .join (" ," ) })
380
+ }
383
381
}
384
- }
385
- let fields = []
386
- if ( s .matchFields ) {
387
- for ( const express of s . matchFields ) {
388
- fields . push ({ key : express . key , operator : express . operator , value : express . values . join ( " , " ) })
382
+ let fields = []
383
+ if ( s . matchFields ) {
384
+ for ( const express of s .matchFields ) {
385
+ fields . push ({ key : express . key , operator : express . operator , value : express . values . join ( " , " ) })
386
+ }
389
387
}
388
+ this .nodeSchedulings .push ({ priority: " Required" , rules: rules, fields: fields })
390
389
}
391
- this .nodeSchedulings .push ({ priority: " Required" , rules: rules, fields: fields })
392
390
}
393
391
}
394
- }
395
- if ( this .podSchedulingParentObj .nodeAffinity .preferredDuringSchedulingIgnoredDuringExecution ) {
396
- const schedulings = this . podSchedulingParentObj . nodeAffinity . preferredDuringSchedulingIgnoredDuringExecution
397
- for ( const s of schedulings) {
398
- let rules = []
399
- let fields = []
400
- if (s .preference ) {
401
- if ( s .preference .matchExpressions ) {
402
- for ( const express of s . preference . matchExpressions ) {
403
- rules . push ({ key : express . key , operator : express . operator , value : express . values . join ( " , " ) })
392
+ if ( this . podSchedulingParentObj . affinity . nodeAffinity . preferredDuringSchedulingIgnoredDuringExecution ) {
393
+ const schedulings = this .podSchedulingParentObj .affinity . nodeAffinity .preferredDuringSchedulingIgnoredDuringExecution
394
+ for ( const s of schedulings) {
395
+ let rules = []
396
+ let fields = []
397
+ if ( s . preference ) {
398
+ if (s .preference . matchExpressions ) {
399
+ for ( const express of s .preference .matchExpressions ) {
400
+ rules . push ({ key : express . key , operator : express . operator , value : express . values . join ( " , " ) })
401
+ }
404
402
}
405
- }
406
- if ( s .preference .matchFields ) {
407
- for ( const express of s . preference . matchFields ) {
408
- fields . push ({ key : express . key , operator : express . operator , value : express . values . join ( " , " ) })
403
+ if ( s . preference . matchFields ) {
404
+ for ( const express of s .preference .matchFields ) {
405
+ fields . push ({ key : express . key , operator : express . operator , value : express . values . join ( " , " ) })
406
+ }
409
407
}
410
408
}
409
+ this .nodeSchedulings .push ({ priority: " Preferred" , rules: rules, fields: fields, weight: s .weight || null })
411
410
}
412
- this .nodeSchedulings .push ({ priority: " Preferred" , rules: rules, fields: fields, weight: s .weight || null })
413
411
}
414
412
}
415
413
}
0 commit comments