pan3793 commented on code in PR #53840:
URL: https://github.com/apache/spark/pull/53840#discussion_r2834579909
##########
resource-managers/kubernetes/core/src/main/scala/org/apache/spark/scheduler/cluster/k8s/KubernetesClusterManager.scala:
##########
@@ -184,13 +188,30 @@ private[spark] class KubernetesClusterManager extends
ExternalClusterManager wit
classOf[SparkConf], classOf[org.apache.spark.SecurityManager],
classOf[KubernetesExecutorBuilder], classOf[KubernetesClient],
classOf[ExecutorPodsSnapshotsStore], classOf[Clock])
- cstr.newInstance(
+ val allocatorInstance = cstr.newInstance(
sc.conf,
sc.env.securityManager,
new KubernetesExecutorBuilder(),
kubernetesClient,
snapshotsStore,
new SystemClock())
+
+ // Try to set the lifecycle manager using reflection for backward
compatibility
+ // with custom allocators that may not have this method
+ lifecycleManager.foreach { manager =>
+ try {
+ val setLifecycleManagerMethod = cls.getMethod(
+ "setExecutorPodsLifecycleManager",
+ classOf[ExecutorPodsLifecycleManager])
+ setLifecycleManagerMethod.invoke(allocatorInstance, manager)
+ } catch {
+ case _: NoSuchMethodException =>
+ logInfo("Allocator does not support setExecutorPodsLifecycleManager
method. " +
+ "Pod creation failures will not be tracked.")
Review Comment:
Method `setExecutorPodsLifecycleManager` is added in
`AbstractPodsAllocator`, not the derived class. Is reflection really required
here?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]