navinvishy commented on code in PR #48446:
URL: https://github.com/apache/spark/pull/48446#discussion_r1805827506
##########
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:
Sorry @pan3793 minor correction to what I said earlier. The priority comes
from the factory itself. So if there are multiple options, we could extend the
factory we want and assign priority, like this:
```
class MyHttpClientFactory extends JdkHttpClientFactory {
override def priority(): Int = -1
}
```
and then add `MyHttpClientFactory` to the configuration file.
Regardless, with this change it should be possible to choose an
implementation without touching code.
--
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]