Skip to content

Commit 6ae1b2f

Browse files
Kevinz857Kevinmmt
andauthored
feat: support driver and executor pod use different priority (#2146)
* feat: support driver and executor pod use different priority Signed-off-by: Kevin Wu <kevin.wu@momenta.ai> * feat: if *app.Spec.Driver.PriorityClassName and *app.Spec.Executor.PriorityClassName specifically defined, then can precedence over spec.batchSchedulerOptions.priorityClassName Signed-off-by: Kevin Wu <kevin.wu@momenta.ai> * feat: merge the logic of setPodPriorityClassName into addPriorityClassName Signed-off-by: Kevin Wu <kevin.wu@momenta.ai> * feat: support driver and executor pod use different priority Signed-off-by: Kevin Wu <kevin.wu@momenta.ai> Signed-off-by: Kevin.Wu <kevin.wu@momenta.ai> * feat: if *app.Spec.Driver.PriorityClassName and *app.Spec.Executor.PriorityClassName specifically defined, then can precedence over spec.batchSchedulerOptions.priorityClassName Signed-off-by: Kevin Wu <kevin.wu@momenta.ai> Signed-off-by: Kevin.Wu <kevin.wu@momenta.ai> * feat: merge the logic of setPodPriorityClassName into addPriorityClassName Signed-off-by: Kevin Wu <kevin.wu@momenta.ai> Signed-off-by: Kevin.Wu <kevin.wu@momenta.ai> * feat: add adjust pointer if is nil Signed-off-by: Kevin.Wu <kevin.wu@momenta.ai> * feat: remove spec.batchSchedulerOptions.priorityClassName define , split driver and executor pod priorityClass Signed-off-by: Kevin Wu <kevin.wu@momenta.ai> * feat: remove spec.batchSchedulerOptions.priorityClassName define , split driver and executor pod priorityClass Signed-off-by: Kevin Wu <kevin.wu@momenta.ai> * feat: Optimize code to avoid null pointer exceptions Signed-off-by: Kevin.Wu <kevin.wu@momenta.ai> * fix: remove backup crd files Signed-off-by: Kevin.Wu <kevin.wu@momenta.ai> * fix: remove BatchSchedulerOptions.PriorityClassName test code Signed-off-by: Kevin Wu <kevin.wu@momenta.ai> * fix: add driver and executor pod priorityClassName test code Signed-off-by: Kevin Wu <kevin.wu@momenta.ai> --------- Signed-off-by: Kevin Wu <kevin.wu@momenta.ai> Signed-off-by: Kevin.Wu <kevin.wu@momenta.ai> Co-authored-by: Kevin Wu <kevin.wu@momenta.ai>
1 parent 95d202e commit 6ae1b2f

9 files changed

+84
-13
lines changed

api/v1beta2/sparkapplication_types.go

+6
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,9 @@ type DriverSpec struct {
536536
// Ports settings for the pods, following the Kubernetes specifications.
537537
// +optional
538538
Ports []Port `json:"ports,omitempty"`
539+
// PriorityClassName is the name of the PriorityClass for the driver pod.
540+
// +optional
541+
PriorityClassName *string `json:"priorityClassName,omitempty"`
539542
}
540543

541544
// ExecutorSpec is specification of the executor.
@@ -563,6 +566,9 @@ type ExecutorSpec struct {
563566
// Ports settings for the pods, following the Kubernetes specifications.
564567
// +optional
565568
Ports []Port `json:"ports,omitempty"`
569+
// PriorityClassName is the name of the PriorityClass for the executor pod.
570+
// +optional
571+
PriorityClassName *string `json:"priorityClassName,omitempty"`
566572
}
567573

568574
// NamePath is a pair of a name and a path to which the named objects should be mounted to.

api/v1beta2/zz_generated.deepcopy.go

+10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

charts/spark-operator-chart/crds/sparkoperator.k8s.io_scheduledsparkapplications.yaml

+8
Original file line numberDiff line numberDiff line change
@@ -3179,6 +3179,10 @@ spec:
31793179
- protocol
31803180
type: object
31813181
type: array
3182+
priorityClassName:
3183+
description: PriorityClassName is the name of the PriorityClass
3184+
for the driver pod.
3185+
type: string
31823186
schedulerName:
31833187
description: SchedulerName specifies the scheduler that will
31843188
be used for scheduling
@@ -7946,6 +7950,10 @@ spec:
79467950
- protocol
79477951
type: object
79487952
type: array
7953+
priorityClassName:
7954+
description: PriorityClassName is the name of the PriorityClass
7955+
for the executor pod.
7956+
type: string
79497957
schedulerName:
79507958
description: SchedulerName specifies the scheduler that will
79517959
be used for scheduling

charts/spark-operator-chart/crds/sparkoperator.k8s.io_sparkapplications.yaml

+8
Original file line numberDiff line numberDiff line change
@@ -3127,6 +3127,10 @@ spec:
31273127
- protocol
31283128
type: object
31293129
type: array
3130+
priorityClassName:
3131+
description: PriorityClassName is the name of the PriorityClass
3132+
for the driver pod.
3133+
type: string
31303134
schedulerName:
31313135
description: SchedulerName specifies the scheduler that will be
31323136
used for scheduling
@@ -7864,6 +7868,10 @@ spec:
78647868
- protocol
78657869
type: object
78667870
type: array
7871+
priorityClassName:
7872+
description: PriorityClassName is the name of the PriorityClass
7873+
for the executor pod.
7874+
type: string
78677875
schedulerName:
78687876
description: SchedulerName specifies the scheduler that will be
78697877
used for scheduling

config/crd/bases/sparkoperator.k8s.io_scheduledsparkapplications.yaml

+8
Original file line numberDiff line numberDiff line change
@@ -3179,6 +3179,10 @@ spec:
31793179
- protocol
31803180
type: object
31813181
type: array
3182+
priorityClassName:
3183+
description: PriorityClassName is the name of the PriorityClass
3184+
for the driver pod.
3185+
type: string
31823186
schedulerName:
31833187
description: SchedulerName specifies the scheduler that will
31843188
be used for scheduling
@@ -7946,6 +7950,10 @@ spec:
79467950
- protocol
79477951
type: object
79487952
type: array
7953+
priorityClassName:
7954+
description: PriorityClassName is the name of the PriorityClass
7955+
for the executor pod.
7956+
type: string
79497957
schedulerName:
79507958
description: SchedulerName specifies the scheduler that will
79517959
be used for scheduling

config/crd/bases/sparkoperator.k8s.io_sparkapplications.yaml

+8
Original file line numberDiff line numberDiff line change
@@ -3127,6 +3127,10 @@ spec:
31273127
- protocol
31283128
type: object
31293129
type: array
3130+
priorityClassName:
3131+
description: PriorityClassName is the name of the PriorityClass
3132+
for the driver pod.
3133+
type: string
31303134
schedulerName:
31313135
description: SchedulerName specifies the scheduler that will be
31323136
used for scheduling
@@ -7864,6 +7868,10 @@ spec:
78647868
- protocol
78657869
type: object
78667870
type: array
7871+
priorityClassName:
7872+
description: PriorityClassName is the name of the PriorityClass
7873+
for the executor pod.
7874+
type: string
78677875
schedulerName:
78687876
description: SchedulerName specifies the scheduler that will be
78697877
used for scheduling

docs/api-docs.md

+24
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,18 @@ executors to connect to the driver.</p>
625625
<p>Ports settings for the pods, following the Kubernetes specifications.</p>
626626
</td>
627627
</tr>
628+
<tr>
629+
<td>
630+
<code>priorityClassName</code><br/>
631+
<em>
632+
string
633+
</em>
634+
</td>
635+
<td>
636+
<em>(Optional)</em>
637+
<p>PriorityClassName is the name of the PriorityClass for the driver pod.</p>
638+
</td>
639+
</tr>
628640
</tbody>
629641
</table>
630642
<h3 id="sparkoperator.k8s.io/v1beta2.DriverState">DriverState
@@ -840,6 +852,18 @@ Maps to <code>spark.kubernetes.executor.deleteOnTermination</code> that is avail
840852
<p>Ports settings for the pods, following the Kubernetes specifications.</p>
841853
</td>
842854
</tr>
855+
<tr>
856+
<td>
857+
<code>priorityClassName</code><br/>
858+
<em>
859+
string
860+
</em>
861+
</td>
862+
<td>
863+
<em>(Optional)</em>
864+
<p>PriorityClassName is the name of the PriorityClass for the executor pod.</p>
865+
</td>
866+
</tr>
843867
</tbody>
844868
</table>
845869
<h3 id="sparkoperator.k8s.io/v1beta2.ExecutorState">ExecutorState

internal/webhook/sparkpod_defaulter.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -477,19 +477,19 @@ func addSchedulerName(pod *corev1.Pod, app *v1beta2.SparkApplication) error {
477477

478478
func addPriorityClassName(pod *corev1.Pod, app *v1beta2.SparkApplication) error {
479479
var priorityClassName *string
480-
if app.Spec.BatchSchedulerOptions != nil {
481-
priorityClassName = app.Spec.BatchSchedulerOptions.PriorityClassName
480+
481+
if util.IsDriverPod(pod) {
482+
priorityClassName = app.Spec.Driver.PriorityClassName
483+
} else if util.IsExecutorPod(pod) {
484+
priorityClassName = app.Spec.Executor.PriorityClassName
482485
}
483486

484487
if priorityClassName != nil && *priorityClassName != "" {
485488
pod.Spec.PriorityClassName = *priorityClassName
486-
if pod.Spec.Priority != nil {
487-
pod.Spec.Priority = nil
488-
}
489-
if pod.Spec.PreemptionPolicy != nil {
490-
pod.Spec.PreemptionPolicy = nil
491-
}
489+
pod.Spec.Priority = nil
490+
pod.Spec.PreemptionPolicy = nil
492491
}
492+
493493
return nil
494494
}
495495

internal/webhook/sparkpod_defaulter_test.go

+4-5
Original file line numberDiff line numberDiff line change
@@ -781,14 +781,13 @@ func TestPatchSparkPod_PriorityClassName(t *testing.T) {
781781
UID: "spark-test-1",
782782
},
783783
Spec: v1beta2.SparkApplicationSpec{
784-
BatchSchedulerOptions: &v1beta2.BatchSchedulerConfiguration{
785-
PriorityClassName: &priorityClassName,
786-
},
787784
Driver: v1beta2.DriverSpec{
788-
SparkPodSpec: v1beta2.SparkPodSpec{},
785+
SparkPodSpec: v1beta2.SparkPodSpec{},
786+
PriorityClassName: &priorityClassName,
789787
},
790788
Executor: v1beta2.ExecutorSpec{
791-
SparkPodSpec: v1beta2.SparkPodSpec{},
789+
SparkPodSpec: v1beta2.SparkPodSpec{},
790+
PriorityClassName: &priorityClassName,
792791
},
793792
},
794793
}

0 commit comments

Comments
 (0)