navinvishy commented on code in PR #48446:
URL: https://github.com/apache/spark/pull/48446#discussion_r1802389987


##########
resource-managers/kubernetes/core/src/main/scala/org/apache/spark/deploy/k8s/SparkKubernetesClientFactory.scala:
##########
@@ -103,42 +100,43 @@ object SparkKubernetesClientFactory extends Logging {
       .withRequestTimeout(clientType.requestTimeout(sparkConf))
       .withConnectionTimeout(clientType.connectionTimeout(sparkConf))
       .withTrustCerts(sparkConf.get(KUBERNETES_TRUST_CERTIFICATES))
-      .withOption(oauthTokenValue) {
-        (token, configBuilder) => configBuilder.withOauthToken(token)
-      }.withOption(oauthTokenFile) {
-        (file, configBuilder) =>
-            configBuilder.withOauthToken(Files.asCharSource(file, 
Charsets.UTF_8).read())
-      }.withOption(caCertFile) {
-        (file, configBuilder) => configBuilder.withCaCertFile(file)
-      }.withOption(clientKeyFile) {
-        (file, configBuilder) => configBuilder.withClientKeyFile(file)
-      }.withOption(clientCertFile) {
-        (file, configBuilder) => configBuilder.withClientCertFile(file)
-      }.withOption(namespace) {
-        (ns, configBuilder) => configBuilder.withNamespace(ns)
-      }.build()
-    val factoryWithCustomDispatcher = new OkHttpClientFactory() {
-      override protected def additionalConfig(builder: OkHttpClient.Builder): 
Unit = {
-        builder.dispatcher(dispatcher)
+      .withOption(oauthTokenValue) { (token, configBuilder) =>
+        configBuilder.withOauthToken(token)
       }
-    }
-    logDebug("Kubernetes client config: " +
-      new 
ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(config))
+      .withOption(oauthTokenFile) { (file, configBuilder) =>
+        configBuilder.withOauthToken(Files.asCharSource(file, 
Charsets.UTF_8).read())
+      }
+      .withOption(caCertFile) { (file, configBuilder) =>
+        configBuilder.withCaCertFile(file)
+      }
+      .withOption(clientKeyFile) { (file, configBuilder) =>
+        configBuilder.withClientKeyFile(file)
+      }
+      .withOption(clientCertFile) { (file, configBuilder) =>
+        configBuilder.withClientCertFile(file)
+      }
+      .withOption(namespace) { (ns, configBuilder) =>
+        configBuilder.withNamespace(ns)
+      }
+      .build()
+    logDebug(
+      "Kubernetes client config: " +
+        new 
ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(config))
     new KubernetesClientBuilder()
-      .withHttpClientFactory(factoryWithCustomDispatcher)

Review Comment:
   In the job jar, you would include a dependency on another http client, for 
eg.
   ```
   <dependency>
       <groupId>io.fabric8</groupId>
       <artifactId>kubernetes-httpclient-jdk</artifactId>
     </dependency>
   ```
   These dependency jars contain the file 
`META-INF/services/io.fabric8.kubernetes.client.http.HttpClient$Factory` 
containing the name of the class implementing the provider, which the K8s 
client builder should pick up.
   
   The job jar could also include 
`META-INF/services/io.fabric8.kubernetes.client.http.HttpClient$Factory` with 
the name of the class we want to use.
   
   I'll restore the changes - somehow running `/dev/scalafmt` introduced those.



-- 
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]

Reply via email to