-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-36462][K8S] Add the ability to selectively disable watching or polling #36433
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
Changes from all commits
2ed6c6b
efa0e5a
eac0698
a030c0b
346f40f
6fef69d
c8523c1
9137c4d
f0db5a7
adf4e9a
9f5d460
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,7 +22,9 @@ import io.fabric8.kubernetes.api.model.Pod | |
| import io.fabric8.kubernetes.client.{KubernetesClient, Watcher, WatcherException} | ||
| import io.fabric8.kubernetes.client.Watcher.Action | ||
|
|
||
| import org.apache.spark.{SparkConf, SparkContext} | ||
| import org.apache.spark.annotation.{DeveloperApi, Since, Stable} | ||
| import org.apache.spark.deploy.k8s.Config.KUBERNETES_EXECUTOR_ENABLE_API_WATCHER | ||
| import org.apache.spark.deploy.k8s.Constants._ | ||
| import org.apache.spark.internal.Logging | ||
| import org.apache.spark.util.Utils | ||
|
|
@@ -38,19 +40,28 @@ import org.apache.spark.util.Utils | |
| @DeveloperApi | ||
| class ExecutorPodsWatchSnapshotSource( | ||
| snapshotsStore: ExecutorPodsSnapshotsStore, | ||
| kubernetesClient: KubernetesClient) extends Logging { | ||
| kubernetesClient: KubernetesClient, | ||
| conf: SparkConf) extends Logging { | ||
|
Member
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. Oh, this is a developer API as
Contributor
Author
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. Sure :) |
||
|
|
||
| private var watchConnection: Closeable = _ | ||
| private val enableWatching = conf.get(KUBERNETES_EXECUTOR_ENABLE_API_WATCHER) | ||
|
|
||
| // If we're constructed with the old API get the SparkConf from the running SparkContext. | ||
| def this(snapshotsStore: ExecutorPodsSnapshotsStore, kubernetesClient: KubernetesClient) = { | ||
| this(snapshotsStore, kubernetesClient, SparkContext.getOrCreate().conf) | ||
| } | ||
|
|
||
| @Since("3.1.3") | ||
| def start(applicationId: String): Unit = { | ||
| require(watchConnection == null, "Cannot start the watcher twice.") | ||
| logDebug(s"Starting watch for pods with labels $SPARK_APP_ID_LABEL=$applicationId," + | ||
| s" $SPARK_ROLE_LABEL=$SPARK_POD_EXECUTOR_ROLE.") | ||
| watchConnection = kubernetesClient.pods() | ||
| .withLabel(SPARK_APP_ID_LABEL, applicationId) | ||
| .withLabel(SPARK_ROLE_LABEL, SPARK_POD_EXECUTOR_ROLE) | ||
| .watch(new ExecutorPodsWatcher()) | ||
| if (enableWatching) { | ||
| require(watchConnection == null, "Cannot start the watcher twice.") | ||
| logDebug(s"Starting to watch for pods with labels $SPARK_APP_ID_LABEL=$applicationId," + | ||
| s" $SPARK_ROLE_LABEL=$SPARK_POD_EXECUTOR_ROLE.") | ||
| watchConnection = kubernetesClient.pods() | ||
| .withLabel(SPARK_APP_ID_LABEL, applicationId) | ||
| .withLabel(SPARK_ROLE_LABEL, SPARK_POD_EXECUTOR_ROLE) | ||
| .watch(new ExecutorPodsWatcher()) | ||
| } | ||
| } | ||
|
|
||
| @Since("3.1.3") | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.