@@ -347,18 +347,10 @@ func calPgMinResource(minMember *int32, mpiJob *kubeflow.MPIJob, pFunc PriorityC
347
347
ReplicaSpec : * replica ,
348
348
}
349
349
350
- pcName := replica .Template .Spec .PriorityClassName
351
- if len (pcName ) != 0 && pFunc != nil {
352
- if priorityClass , err := pFunc (pcName ); err != nil {
353
- klog .Warningf ("Ignore replica %q priority class %q: %v" , rt , pcName , err )
354
- } else {
355
- rp .priority = priorityClass .Value
356
- }
357
- }
350
+ rp .priority = calculatePriority (& replica .Template .Spec , pFunc )
358
351
order = append (order , rp )
359
352
}
360
353
361
-
362
354
sort .Sort (sort .Reverse (order ))
363
355
// Launcher + Worker > minMember
364
356
if minMember != nil && * order [0 ].Replicas + * order [1 ].Replicas > * minMember {
@@ -417,6 +409,28 @@ func calculatePriorityClassName(
417
409
}
418
410
}
419
411
412
+ // calculatePriority set priority
413
+ // 1. set priority with priorityClass's value
414
+ // 2. set priority with priority
415
+ func calculatePriority (podSpec * corev1.PodSpec , pFunc PriorityClassGetFunc ) int32 {
416
+ var priority int32
417
+ pcName := podSpec .PriorityClassName
418
+ if len (pcName ) != 0 && pFunc != nil {
419
+ if priorityClass , err := pFunc (pcName ); err != nil {
420
+ klog .Warningf ("Ignore priority class %q: %v" , pcName , err )
421
+ if podSpec .Priority != nil {
422
+ priority = * podSpec .Priority
423
+ }
424
+ } else {
425
+ priority = priorityClass .Value
426
+ }
427
+ } else if podSpec .Priority != nil {
428
+ priority = * podSpec .Priority
429
+ }
430
+
431
+ return priority
432
+ }
433
+
420
434
// addResources adds resources to minResources.
421
435
// If resources don't have requests, it defaults limit if that is explicitly specified.
422
436
func addResources (minResources corev1.ResourceList , resources corev1.ResourceRequirements ) {
0 commit comments