Repository navigation
[SPARK-59542] Support spec.suspend to hold driver and master/worker creation in AppInitStep and ClusterInitStep
#828
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
d778c50
[SPARK-59542] Support `spec.suspend` to hold driver and StatefulSet c…
dongjoon-hyun 5351a9a
Address comments
dongjoon-hyun 34dbda1
Address comments
dongjoon-hyun 67d1cfc
Address comments
dongjoon-hyun 18636ac
Address comments
dongjoon-hyun File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -380,7 +380,9 @@ restartConfig: | |||||||
| The `restartCounterResetMillis` field controls automatic restart counter resets for long-running | ||||||||
| application attempts. When set to a non-negative value (in milliseconds), the operator will reset | ||||||||
| all restart counters (including the general counter and both failure counters) if an application | ||||||||
| attempt runs successfully for at least the specified duration before ending. | ||||||||
| attempt runs successfully for at least the specified duration before ending. The duration is | ||||||||
| measured from the first state after `Submitted` / `ScheduledToRestart` (normally | ||||||||
| `DriverRequested`), so time spent in restart backoff or suspended is not counted. | ||||||||
|
|
||||||||
| Time-based reset takes highest precedence over all limit checks. If an attempt runs longer than | ||||||||
| `restartCounterResetMillis`, the operator will always restart with reset counters, regardless | ||||||||
|
|
@@ -525,6 +527,40 @@ Note that `ttlAfterStopMillis` applies to the app as well as its secondary resou | |||||||
| latter is smaller, then it takes higher precedence: operator would remove all resources related | ||||||||
| to this app after `ttlAfterStopMillis`. | ||||||||
|
|
||||||||
| ## Suspend | ||||||||
|
|
||||||||
| Both `SparkApplication` and `SparkCluster` support `.spec.suspend`. When it is set to `true`, the | ||||||||
| operator keeps the resource in its initializing state (`Submitted`, or `ScheduledToRestart` for an | ||||||||
| application that is scheduled to restart) and does not request the driver pod or the master / worker | ||||||||
| StatefulSets. Setting it back to `false` resumes the regular lifecycle. | ||||||||
|
|
||||||||
| `Submitted` here is the operator's in-memory view. For a valid resource created with | ||||||||
| `suspend: true`, the initial `Submitted` status is not persisted to the API server, so | ||||||||
| `kubectl get` shows an empty `Current State` until initialization resumes. An application held | ||||||||
| later, in `ScheduledToRestart`, keeps the status its previous attempt already wrote. | ||||||||
|
|
||||||||
| ``` yaml | ||||||||
| apiVersion: spark.apache.org/v1 | ||||||||
| kind: SparkApplication | ||||||||
| metadata: | ||||||||
| name: suspended-pi | ||||||||
| spec: | ||||||||
| suspend: true | ||||||||
| mainClass: "org.apache.spark.examples.SparkPi" | ||||||||
| jars: "local:///opt/spark/examples/jars/spark-examples.jar" | ||||||||
| runtimeVersions: | ||||||||
| sparkVersion: "4.2.0" | ||||||||
| ``` | ||||||||
|
|
||||||||
| * `suspend` only takes effect before the driver (or master / worker) resources are requested. | ||||||||
| Setting it to `true` on a running application does not stop the current attempt. If the | ||||||||
| application is configured to restart, the next attempt is held until `suspend` is set back to | ||||||||
| `false`. Setting it to `true` on a running cluster has no effect in the current version. | ||||||||
| * Deleting a suspended resource works as usual. | ||||||||
| * This is the building block for external job queueing systems such as | ||||||||
| [Kueue](https://kueue.sigs.k8s.io/), which admit a workload by flipping `suspend` to `false`. | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Finding 9. Reads as if Kueue does this today.
Suggested change
|
||||||||
| The operator does not integrate with such a system yet. | ||||||||
|
|
||||||||
| ## Spark Cluster | ||||||||
|
|
||||||||
| Spark Operator also supports launching Spark clusters in k8s via `SparkCluster` custom resource, | ||||||||
|
|
||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Finding 6.
Submittedis not something the user can observe here. With the dedicatedSuspendedstate deferred to a follow-up (#issuecomment-5684180823), the docs are the only place that can say so.For a
SparkApplicationcreated withsuspend: true, no step in the pipeline writes a status.AppValidateSteppersists only when the status is invalid and it never is.AppCleanUpStepreturnsproceed()forSubmitted. The new branch returns before any persist.toUpdateControlisnoUpdate(). So.statusis absent on the API server and theCurrent Stateprinter column is blank.That is indistinguishable from "the operator is not watching this namespace".
tests/e2e/watched-namespaces/chainsaw-test.yaml:54-58asserts.status == nullas the signature of exactly that case.Worth stating precisely, because the paragraph is only wrong for one of the two holds. An application suspended later, in
ScheduledToRestart, does have a status on the server.AppCleanUpStepwrote it before the app got there.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This distinction is still missing from the documentation at the current head. A valid resource created with
suspend: truedoes not have its initial status persisted, soSubmittedis an in-memory state and theCurrent Statecolumn remains blank. An application held inScheduledToRestart, however, retains the status already written by cleanup.Deferring a dedicated
Suspendedstate seems reasonable for this PR, but please document the observable behavior explicitly. For example:The PR description's statement that a held resource has no
.statusshould likewise be limited to the initial-submission case.