Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions api/v1beta2/sparkapplication_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,9 @@ type DriverSpec struct {
// Ports settings for the pods, following the Kubernetes specifications.
// +optional
Ports []Port `json:"ports,omitempty"`
// PriorityClassName is the name of the PriorityClass for the driver pod.
// +optional
PriorityClassName *string `json:"priorityClassName,omitempty"`
}

// ExecutorSpec is specification of the executor.
Expand Down Expand Up @@ -563,6 +566,9 @@ type ExecutorSpec struct {
// Ports settings for the pods, following the Kubernetes specifications.
// +optional
Ports []Port `json:"ports,omitempty"`
// PriorityClassName is the name of the PriorityClass for the executor pod.
// +optional
PriorityClassName *string `json:"priorityClassName,omitempty"`
}

// NamePath is a pair of a name and a path to which the named objects should be mounted to.
Expand Down
10 changes: 10 additions & 0 deletions api/v1beta2/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -3179,6 +3179,10 @@ spec:
- protocol
type: object
type: array
priorityClassName:
description: PriorityClassName is the name of the PriorityClass
for the driver pod.
type: string
schedulerName:
description: SchedulerName specifies the scheduler that will
be used for scheduling
Expand Down Expand Up @@ -7946,6 +7950,10 @@ spec:
- protocol
type: object
type: array
priorityClassName:
description: PriorityClassName is the name of the PriorityClass
for the executor pod.
type: string
schedulerName:
description: SchedulerName specifies the scheduler that will
be used for scheduling
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3127,6 +3127,10 @@ spec:
- protocol
type: object
type: array
priorityClassName:
description: PriorityClassName is the name of the PriorityClass
for the driver pod.
type: string
schedulerName:
description: SchedulerName specifies the scheduler that will be
used for scheduling
Expand Down Expand Up @@ -7864,6 +7868,10 @@ spec:
- protocol
type: object
type: array
priorityClassName:
description: PriorityClassName is the name of the PriorityClass
for the executor pod.
type: string
schedulerName:
description: SchedulerName specifies the scheduler that will be
used for scheduling
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3179,6 +3179,10 @@ spec:
- protocol
type: object
type: array
priorityClassName:
description: PriorityClassName is the name of the PriorityClass
for the driver pod.
type: string
schedulerName:
description: SchedulerName specifies the scheduler that will
be used for scheduling
Expand Down Expand Up @@ -7946,6 +7950,10 @@ spec:
- protocol
type: object
type: array
priorityClassName:
description: PriorityClassName is the name of the PriorityClass
for the executor pod.
type: string
schedulerName:
description: SchedulerName specifies the scheduler that will
be used for scheduling
Expand Down
8 changes: 8 additions & 0 deletions config/crd/bases/sparkoperator.k8s.io_sparkapplications.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3127,6 +3127,10 @@ spec:
- protocol
type: object
type: array
priorityClassName:
description: PriorityClassName is the name of the PriorityClass
for the driver pod.
type: string
schedulerName:
description: SchedulerName specifies the scheduler that will be
used for scheduling
Expand Down Expand Up @@ -7864,6 +7868,10 @@ spec:
- protocol
type: object
type: array
priorityClassName:
description: PriorityClassName is the name of the PriorityClass
for the executor pod.
type: string
schedulerName:
description: SchedulerName specifies the scheduler that will be
used for scheduling
Expand Down
24 changes: 24 additions & 0 deletions docs/api-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,18 @@ executors to connect to the driver.</p>
<p>Ports settings for the pods, following the Kubernetes specifications.</p>
</td>
</tr>
<tr>
<td>
<code>priorityClassName</code><br/>
<em>
string
</em>
</td>
<td>
<em>(Optional)</em>
<p>PriorityClassName is the name of the PriorityClass for the driver pod.</p>
</td>
</tr>
</tbody>
</table>
<h3 id="sparkoperator.k8s.io/v1beta2.DriverState">DriverState
Expand Down Expand Up @@ -840,6 +852,18 @@ Maps to <code>spark.kubernetes.executor.deleteOnTermination</code> that is avail
<p>Ports settings for the pods, following the Kubernetes specifications.</p>
</td>
</tr>
<tr>
<td>
<code>priorityClassName</code><br/>
<em>
string
</em>
</td>
<td>
<em>(Optional)</em>
<p>PriorityClassName is the name of the PriorityClass for the executor pod.</p>
</td>
</tr>
</tbody>
</table>
<h3 id="sparkoperator.k8s.io/v1beta2.ExecutorState">ExecutorState
Expand Down
16 changes: 8 additions & 8 deletions internal/webhook/sparkpod_defaulter.go
Original file line number Diff line number Diff line change
Expand Up @@ -477,19 +477,19 @@ func addSchedulerName(pod *corev1.Pod, app *v1beta2.SparkApplication) error {

func addPriorityClassName(pod *corev1.Pod, app *v1beta2.SparkApplication) error {
var priorityClassName *string
if app.Spec.BatchSchedulerOptions != nil {
priorityClassName = app.Spec.BatchSchedulerOptions.PriorityClassName

if util.IsDriverPod(pod) {
priorityClassName = app.Spec.Driver.PriorityClassName
} else if util.IsExecutorPod(pod) {
priorityClassName = app.Spec.Executor.PriorityClassName
}

if priorityClassName != nil && *priorityClassName != "" {
pod.Spec.PriorityClassName = *priorityClassName
if pod.Spec.Priority != nil {
pod.Spec.Priority = nil
}
if pod.Spec.PreemptionPolicy != nil {
pod.Spec.PreemptionPolicy = nil
}
pod.Spec.Priority = nil
pod.Spec.PreemptionPolicy = nil
}

return nil
}

Expand Down
9 changes: 4 additions & 5 deletions internal/webhook/sparkpod_defaulter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -781,14 +781,13 @@ func TestPatchSparkPod_PriorityClassName(t *testing.T) {
UID: "spark-test-1",
},
Spec: v1beta2.SparkApplicationSpec{
BatchSchedulerOptions: &v1beta2.BatchSchedulerConfiguration{
PriorityClassName: &priorityClassName,
},
Driver: v1beta2.DriverSpec{
SparkPodSpec: v1beta2.SparkPodSpec{},
SparkPodSpec: v1beta2.SparkPodSpec{},
PriorityClassName: &priorityClassName,
},
Executor: v1beta2.ExecutorSpec{
SparkPodSpec: v1beta2.SparkPodSpec{},
SparkPodSpec: v1beta2.SparkPodSpec{},
PriorityClassName: &priorityClassName,
},
},
}
Expand Down