navinvishy commented on code in PR #48446:
URL: https://github.com/apache/spark/pull/48446#discussion_r1800415468
##########
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:
Yeah I thought so. How about adding something like this?
```
val clientFactory = HttpClientUtils.getHttpClientFactory
val clientBuilder = new KubernetesClientBuilder().withConfig(config)
clientFactory match {
case _: OkHttpClientFactory =>
val dispatcher = new Dispatcher(
ThreadUtils.newDaemonCachedThreadPool("kubernetes-dispatcher"))
val factory = new OkHttpClientFactory() {
override def additionalConfig(builder: OkHttpClient.Builder): Unit = {
builder.dispatcher(dispatcher)
}
}
clientBuilder.withHttpClientFactory(factory).build()
case _ => clientBuilder.build()
}
```
--
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]