pulsar-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sanjee...@apache.org
Subject [pulsar] branch master updated: Secrets provider should be initialized for each new function (#6993)
Date Sat, 23 May 2020 03:41:14 GMT
This is an automated email from the ASF dual-hosted git repository.

sanjeevrk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar.git


The following commit(s) were added to refs/heads/master by this push:
     new 6e6e4e2  Secrets provider should be initialized for each new function (#6993)
6e6e4e2 is described below

commit 6e6e4e28b36717f2b11c69babd4b9d34140ab5b1
Author: Boyang Jerry Peng <jerry.boyang.peng@gmail.com>
AuthorDate: Fri May 22 20:40:58 2020 -0700

    Secrets provider should be initialized for each new function (#6993)
    
    * Secrets provider should be initialized for each new function
    
    * add comment
    
    Co-authored-by: Jerry Peng <jerryp@splunk.com>
---
 .../pulsar/functions/runtime/thread/ThreadRuntimeFactory.java  | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/thread/ThreadRuntimeFactory.java
b/pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/thread/ThreadRuntimeFactory.java
index cb82129..423d1f0 100644
--- a/pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/thread/ThreadRuntimeFactory.java
+++ b/pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/thread/ThreadRuntimeFactory.java
@@ -34,7 +34,6 @@ import org.apache.pulsar.functions.instance.InstanceConfig;
 import org.apache.pulsar.functions.runtime.RuntimeCustomizer;
 import org.apache.pulsar.functions.runtime.RuntimeFactory;
 import org.apache.pulsar.functions.runtime.RuntimeUtils;
-import org.apache.pulsar.functions.secretsprovider.ClearTextSecretsProvider;
 import org.apache.pulsar.functions.secretsprovider.SecretsProvider;
 import org.apache.pulsar.functions.secretsproviderconfigurator.SecretsProviderConfigurator;
 import org.apache.pulsar.functions.utils.Reflections;
@@ -58,13 +57,17 @@ public class ThreadRuntimeFactory implements RuntimeFactory {
     private FunctionCacheManager fnCache;
     private PulsarClient pulsarClient;
     private String storageServiceUrl;
-    private SecretsProvider secretsProvider;
+    private SecretsProvider defaultSecretsProvider;
     private CollectorRegistry collectorRegistry;
     private String narExtractionDirectory;
     private volatile boolean closed;
     private SecretsProviderConfigurator secretsProviderConfigurator;
     private ClassLoader rootClassLoader;
 
+    /**
+     * This constructor is used by other runtimes (e.g. ProcessRuntime and KubernetesRuntime)
that rely on ThreadRuntime to actually run an instance of the function.
+     * When used by other runtimes, the arguments such as secretsProvider and rootClassLoader
will be provided.
+     */
     public ThreadRuntimeFactory(String threadGroupName, String pulsarServiceUrl, String storageServiceUrl,
                                 AuthenticationConfig authConfig, SecretsProvider secretsProvider,
                                 CollectorRegistry collectorRegistry, String narExtractionDirectory,
@@ -112,7 +115,7 @@ public class ThreadRuntimeFactory implements RuntimeFactory {
 
         this.rootClassLoader = rootClassLoader;
         this.secretsProviderConfigurator = secretsProviderConfigurator;
-        this.secretsProvider = secretsProvider;
+        this.defaultSecretsProvider = secretsProvider;
         this.fnCache = new FunctionCacheManagerImpl(rootClassLoader);
         this.threadGroup = new ThreadGroup(threadGroupName);
         this.pulsarClient = pulsarClient;
@@ -139,6 +142,7 @@ public class ThreadRuntimeFactory implements RuntimeFactory {
     public ThreadRuntime createContainer(InstanceConfig instanceConfig, String jarFile,
                                          String originalCodeFileName,
                                          Long expectedHealthCheckInterval) {
+        SecretsProvider secretsProvider = defaultSecretsProvider;
         if (secretsProvider == null) {
             String secretsProviderClassName = secretsProviderConfigurator.getSecretsProviderClassName(instanceConfig.getFunctionDetails());
             secretsProvider = (SecretsProvider) Reflections.createInstance(secretsProviderClassName,
this.rootClassLoader);


Mime
View raw message