-
Notifications
You must be signed in to change notification settings - Fork 29.2k
[SPARK-56238][K8S] Fix app ID propagation in KubernetesClusterSchedulerBackend for client mode submission
#55355
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
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 |
|---|---|---|
|
|
@@ -314,4 +314,36 @@ class KubernetesClusterSchedulerBackendSuite extends SparkFunSuite with BeforeAn | |
| endpoint.receiveAndReply(context).apply(GenerateExecID("cheeseBurger")) | ||
| verify(context).reply("1") | ||
| } | ||
|
|
||
| test("SPARK-56238: applicationId() is stable across calls when spark.app.id is not set") { | ||
| // Use isolated mocks so we don't mutate the shared sc/rpcEnv state. | ||
| val confWithoutAppId = new SparkConf(false) | ||
| .set("spark.executor.instances", "3") | ||
| .set(KUBERNETES_EXECUTOR_DECOMMISSION_LABEL.key, "soLong") | ||
| .set(KUBERNETES_EXECUTOR_DECOMMISSION_LABEL_VALUE.key, "cruelWorld") | ||
| val localSc = mock(classOf[SparkContext]) | ||
| val localEnv = mock(classOf[SparkEnv]) | ||
| val localRpcEnv = mock(classOf[RpcEnv]) | ||
| when(localSc.conf).thenReturn(confWithoutAppId) | ||
| when(localSc.env).thenReturn(localEnv) | ||
| when(localSc.resourceProfileManager).thenReturn(resourceProfileManager) | ||
| when(localEnv.rpcEnv).thenReturn(localRpcEnv) | ||
| when(localRpcEnv.setupEndpoint(any(), any())).thenReturn(driverEndpointRef) | ||
| val localTaskScheduler = mock(classOf[TaskSchedulerImpl]) | ||
| when(localTaskScheduler.sc).thenReturn(localSc) | ||
| val backendWithoutAppId = new KubernetesClusterSchedulerBackend( | ||
|
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. Do you happen to know when this situation happens in the production environment, @xiaoxuandev ? I'm wondering if this is a valid case in the Apache Spark usage.
One more question. Do you know if this is a regression or not? (as Enrico claims)
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. Yes, this is a regression introduced by #54269. The original code cached the generated ID in private val appId, which was correct. Affected versions: v4.2.0-preview3+. All 4.0.x and 4.1.x releases are clean. Regarding production usage: this affects Kubernetes client mode (--deploy-mode client), where the driver runs outside the K8s cluster. In that path, spark.app.id is not pre-set before backend.start(), so each call to applicationId() during start() would generate a different UUID.
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. Got it. Thank you for confirming, @xiaoxuandev . |
||
| localTaskScheduler, | ||
| localSc, | ||
| kubernetesClient, | ||
| schedulerExecutorService, | ||
| eventQueue, | ||
| podAllocator, | ||
| lifecycleManager, | ||
| watchEvents, | ||
| pollEvents) | ||
| val id1 = backendWithoutAppId.applicationId() | ||
| val id2 = backendWithoutAppId.applicationId() | ||
| assert(id1 === id2, "applicationId() must return the same value on repeated calls") | ||
| assert(id1.startsWith("spark-"), "generated app ID should have the spark- prefix") | ||
| } | ||
| } | ||
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 test case seems to reproduce the reported scenario.