You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2021/01/20 12:46:53 UTC

[GitHub] [pulsar] freeznet opened a new pull request #9246: [fix #8089] expose PulsarAdmin client through Function Context

freeznet opened a new pull request #9246:
URL: https://github.com/apache/pulsar/pull/9246


   Fixes #8089
   
   ### Motivation
   
   #8089 addressed that making pulsar admin client api calls is conflict with Jersey library. This PR expose `PulsarAdmin` client through `Function Context`, so the function implementers can use PulsarAdmin to do whatever they want to do.
   
   ### Modifications
   
   - add `getPulsarAdmin()` and `getPulsarAdmin(String clusterName)` in function `Context` 
   - add implementation of above interface in `ContextImpl`
   - add passing `pulsarWebServiceUrl` to function runtimes
   - add passing `pulsarWebServiceUrl` to `LocalRunner` / `JavaInstanceStarter`
   - add `"--web-service-url"` parameter to `LocalRunner` admin command
   - add unit tests
   - add integration tests [WIP]
   
   ### Verifying this change
   
   - [ ] Make sure that the change passes the CI checks.
   
   This change added tests and can be verified as follows:
   
     - add unit tests to verify the args passing from process runtime / k8s runtime to `JavaInstanceStarter`
     - add unit tests to verify `getPulsarAdmin`
     - add integration tests to verify if pulsar admin works well [WIP]
   
   ### Does this pull request potentially affect one of the following parts:
     - The admin cli options: (yes)
   
   ### Documentation
   
     - Does this pull request introduce a new feature? (**yes** / no)
     - If yes, how is the feature documented? (not applicable / docs / JavaDocs / **not documented**)
   


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] freeznet edited a comment on pull request #9246: [fix #8089] expose PulsarAdmin client through Function Context

Posted by GitBox <gi...@apache.org>.
freeznet edited a comment on pull request #9246:
URL: https://github.com/apache/pulsar/pull/9246#issuecomment-766824752


   @eolivelli @sijie @nlu90 code changed according to your review, PTAL when you have time, thanks


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] sijie commented on pull request #9246: [fix #8089] expose PulsarAdmin client through Function Context

Posted by GitBox <gi...@apache.org>.
sijie commented on pull request #9246:
URL: https://github.com/apache/pulsar/pull/9246#issuecomment-763941491


   @nlu90 Can you review this since you add the multiple-cluster support there?


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] lhotari commented on a change in pull request #9246: [fix #8089] expose PulsarAdmin client through Function Context

Posted by GitBox <gi...@apache.org>.
lhotari commented on a change in pull request #9246:
URL: https://github.com/apache/pulsar/pull/9246#discussion_r576105905



##########
File path: pulsar-client-admin-api/pom.xml
##########
@@ -0,0 +1,73 @@
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.pulsar</groupId>
+        <artifactId>pulsar</artifactId>
+        <version>2.8.0-SNAPSHOT</version>
+        <relativePath>..</relativePath>
+    </parent>
+
+    <artifactId>pulsar-client-admin-api</artifactId>
+    <name>Pulsar Client Admin :: API</name>
+
+    <dependencies>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>pulsar-common</artifactId>
+            <version>${project.parent.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>pulsar-client-original</artifactId>
+            <version>${project.parent.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>pulsar-package-core</artifactId>
+            <version>${project.version}</version>
+        </dependency>

Review comment:
       The size of Pulsar IO connectors files get back to normal after changing the scope of `pulsar-client-admin-api` in `pulsar-functions/api-java/pom.xml` from `<scope>compile</scope>` to `<scope>provided</scope>`.
   
   However I'm a bit concerned about the usefulness of the new pulsar-client-admin-api library since it's not really a standalone api dependency. It pulls in all dependencies. WDYT?
   




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] lhotari commented on a change in pull request #9246: [fix #8089] expose PulsarAdmin client through Function Context

Posted by GitBox <gi...@apache.org>.
lhotari commented on a change in pull request #9246:
URL: https://github.com/apache/pulsar/pull/9246#discussion_r576094685



##########
File path: pulsar-client-admin-api/pom.xml
##########
@@ -0,0 +1,73 @@
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.pulsar</groupId>
+        <artifactId>pulsar</artifactId>
+        <version>2.8.0-SNAPSHOT</version>
+        <relativePath>..</relativePath>
+    </parent>
+
+    <artifactId>pulsar-client-admin-api</artifactId>
+    <name>Pulsar Client Admin :: API</name>
+
+    <dependencies>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>pulsar-common</artifactId>
+            <version>${project.parent.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>pulsar-client-original</artifactId>
+            <version>${project.parent.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>pulsar-package-core</artifactId>
+            <version>${project.version}</version>
+        </dependency>

Review comment:
       Is it intentional that these dependencies are included? This change seems to be causing a major regression to Pulsar IO connectors. Please see #9572 . /cc @sijie @eolivelli 




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] freeznet commented on pull request #9246: [fix #8089] expose PulsarAdmin client through Function Context

Posted by GitBox <gi...@apache.org>.
freeznet commented on pull request #9246:
URL: https://github.com/apache/pulsar/pull/9246#issuecomment-770587797


   /pulsarbot run-failure-checks


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] sijie commented on a change in pull request #9246: [fix #8089] expose PulsarAdmin client through Function Context

Posted by GitBox <gi...@apache.org>.
sijie commented on a change in pull request #9246:
URL: https://github.com/apache/pulsar/pull/9246#discussion_r563436302



##########
File path: pulsar-functions/api-java/pom.xml
##########
@@ -49,6 +49,13 @@
       <scope>compile</scope>
     </dependency>
 
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>pulsar-client-admin-original</artifactId>

Review comment:
       @freeznet I don't think we need to rename the packages at this moment. For this pull request, we can just move the files to different modules. That would be sufficient for now. Changing the API classes is a breaking change. We need to think more carefully about that.




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] freeznet commented on a change in pull request #9246: [fix #8089] expose PulsarAdmin client through Function Context

Posted by GitBox <gi...@apache.org>.
freeznet commented on a change in pull request #9246:
URL: https://github.com/apache/pulsar/pull/9246#discussion_r563733287



##########
File path: pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/RuntimeUtils.java
##########
@@ -355,6 +357,14 @@
 
         args.add("--pulsar_serviceurl");
         args.add(pulsarServiceUrl);
+        if (instanceConfig.getFunctionDetails().getRuntime() == Function.FunctionDetails.Runtime.JAVA) {
+            // TODO: for now only Java function context exposed pulsar admin, so python/go no need to pass this argument
+            // until pulsar admin client enabled in python/go function context.
+            if (pulsarWebServiceUrl != null) {

Review comment:
       I agree, flag added, also add some tests when `exposePulsarAdminClientEnabled=false`




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] freeznet commented on pull request #9246: [fix #8089] expose PulsarAdmin client through Function Context

Posted by GitBox <gi...@apache.org>.
freeznet commented on pull request #9246:
URL: https://github.com/apache/pulsar/pull/9246#issuecomment-771237141


   /pulsarbot run-failure-checks


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] freeznet commented on pull request #9246: [fix #8089] expose PulsarAdmin client through Function Context

Posted by GitBox <gi...@apache.org>.
freeznet commented on pull request #9246:
URL: https://github.com/apache/pulsar/pull/9246#issuecomment-773753438


   @codelipenghui will this pr in 2.7.1 release?


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] freeznet commented on pull request #9246: [fix #8089] expose PulsarAdmin client through Function Context

Posted by GitBox <gi...@apache.org>.
freeznet commented on pull request #9246:
URL: https://github.com/apache/pulsar/pull/9246#issuecomment-770604816


   /pulsarbot run-failure-checks


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] freeznet commented on pull request #9246: [fix #8089] expose PulsarAdmin client through Function Context

Posted by GitBox <gi...@apache.org>.
freeznet commented on pull request #9246:
URL: https://github.com/apache/pulsar/pull/9246#issuecomment-770324318


   /pulsarbot run-failure-checks


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] freeznet commented on a change in pull request #9246: [fix #8089] expose PulsarAdmin client through Function Context

Posted by GitBox <gi...@apache.org>.
freeznet commented on a change in pull request #9246:
URL: https://github.com/apache/pulsar/pull/9246#discussion_r561449955



##########
File path: pulsar-functions/api-java/src/main/java/org/apache/pulsar/functions/api/Context.java
##########
@@ -262,6 +264,21 @@
      */
     String getSecret(String secretName);
 
+    /**
+     * Get the pulsar admin client.
+     *
+     * @return The instance of pulsar admin client
+     */
+    PulsarAdmin getPulsarAdmin();
+
+    /**
+     * Get the pulsar admin client by cluster name.

Review comment:
       yes, just as sijie said, `getPulsarAdmin()` will just get the `default` pulsar admin client, the other one will let user get pulsar admin client if `externalPulsarClusters` is set.




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] sijie commented on a change in pull request #9246: [fix #8089] expose PulsarAdmin client through Function Context

Posted by GitBox <gi...@apache.org>.
sijie commented on a change in pull request #9246:
URL: https://github.com/apache/pulsar/pull/9246#discussion_r561328245



##########
File path: pulsar-functions/instance/src/main/java/org/apache/pulsar/functions/instance/InstanceUtils.java
##########
@@ -173,4 +176,25 @@ public static PulsarClient createPulsarClient(String pulsarServiceUrl, Authentic
         }
         return null;
     }
+
+    public static PulsarAdmin createPulsarAdminClient(String pulsarWebServiceUrl, AuthenticationConfig authConfig) throws PulsarClientException {
+        PulsarAdminBuilder pulsarAdminBuilder = null;
+        if (isNotBlank(pulsarWebServiceUrl)) {
+            pulsarAdminBuilder = PulsarAdmin.builder().serviceHttpUrl(pulsarWebServiceUrl);
+            if (authConfig != null) {
+                if (isNotBlank(authConfig.getClientAuthenticationPlugin())
+                        && isNotBlank(authConfig.getClientAuthenticationParameters())) {
+                    pulsarAdminBuilder.authentication(authConfig.getClientAuthenticationPlugin(),
+                            authConfig.getClientAuthenticationParameters());
+                }
+                if (isNotBlank(authConfig.getTlsTrustCertsFilePath())) {
+                    pulsarAdminBuilder.tlsTrustCertsFilePath(authConfig.getTlsTrustCertsFilePath());
+                }
+                pulsarAdminBuilder.allowTlsInsecureConnection(authConfig.isTlsAllowInsecureConnection());
+                pulsarAdminBuilder.enableTlsHostnameVerification(authConfig.isTlsHostnameVerificationEnable());
+            }
+            return pulsarAdminBuilder.build();
+        }
+        return null;

Review comment:
       since the method throws an exception, it might be worth throwing an exception saying the `pulsarWebServiceUrl` is null.

##########
File path: pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdFunctions.java
##########
@@ -617,6 +617,8 @@ protected void validateFunctionConfigs(FunctionConfig functionConfig) {
         protected String DEPRECATED_brokerServiceUrl;
         @Parameter(names = "--broker-service-url", description = "The URL for Pulsar broker")
         protected String brokerServiceUrl;
+        @Parameter(names = "--web-service-url", description = "The URL for Pulsar web service")
+        protected String webServiceUrl;

Review comment:
       I think we need to make this an optional field for backward compatibility.

##########
File path: pulsar-functions/api-java/pom.xml
##########
@@ -49,6 +49,13 @@
       <scope>compile</scope>
     </dependency>
 
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>pulsar-client-admin-original</artifactId>

Review comment:
       @freeznet Can you move the admin API to a separate module (i.e. move them to a `pulsar-client-admin-api` module)? So we don't need to reference an implementation module in the `api-java` module.

##########
File path: pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/JavaInstanceStarter.java
##########
@@ -132,6 +132,9 @@
     @Parameter(names = "--pending_async_requests", description = "Max pending async requests per instance", required = false)
     public int maxPendingAsyncRequests = 1000;
 
+    @Parameter(names = "--web_serviceurl", description = "Pulsar Web Service Url", required = false)
+    public String webServiceUrl;

Review comment:
       Make this field optional for backward compatibility.

##########
File path: pulsar-functions/localrun/src/main/java/org/apache/pulsar/functions/LocalRunner.java
##########
@@ -135,6 +135,8 @@ public RuntimeEnv convert(String value) {
     protected String stateStorageServiceUrl;
     @Parameter(names = "--brokerServiceUrl", description = "The URL for the Pulsar broker", hidden = true)
     protected String brokerServiceUrl;
+    @Parameter(names = "--webServiceUrl", description = "The URL for the Pulsar web service", hidden = true)
+    protected String webServiceUrl;

Review comment:
       Make this optional for backward compatibility.

##########
File path: pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/RuntimeUtils.java
##########
@@ -355,6 +357,14 @@
 
         args.add("--pulsar_serviceurl");
         args.add(pulsarServiceUrl);
+        if (instanceConfig.getFunctionDetails().getRuntime() == Function.FunctionDetails.Runtime.JAVA) {
+            // TODO: for now only Java function context exposed pulsar admin, so python/go no need to pass this argument
+            // until pulsar admin client enabled in python/go function context.
+            if (pulsarWebServiceUrl != null) {

Review comment:
       we need to add a flag in the function worker config to control whether to expose PulsarAdmin through context. Because the new function worker will add this `--web_serviceurl` to the command line that is not able to recognize by the function instance. So we need to have a flag to allow people to do the following update sequence:
   
   1. Update function worker with exposing pulsar admin disabled.
   2. Update all the functions to the new image that understand `--web_serviceurl`
   3. Update function worker to enable exposing pulsar admin.




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] freeznet commented on pull request #9246: [fix #8089] expose PulsarAdmin client through Function Context

Posted by GitBox <gi...@apache.org>.
freeznet commented on pull request #9246:
URL: https://github.com/apache/pulsar/pull/9246#issuecomment-773753438


   @codelipenghui will this pr in 2.7.1 release?


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] sijie commented on a change in pull request #9246: [fix #8089] expose PulsarAdmin client through Function Context

Posted by GitBox <gi...@apache.org>.
sijie commented on a change in pull request #9246:
URL: https://github.com/apache/pulsar/pull/9246#discussion_r561328245



##########
File path: pulsar-functions/instance/src/main/java/org/apache/pulsar/functions/instance/InstanceUtils.java
##########
@@ -173,4 +176,25 @@ public static PulsarClient createPulsarClient(String pulsarServiceUrl, Authentic
         }
         return null;
     }
+
+    public static PulsarAdmin createPulsarAdminClient(String pulsarWebServiceUrl, AuthenticationConfig authConfig) throws PulsarClientException {
+        PulsarAdminBuilder pulsarAdminBuilder = null;
+        if (isNotBlank(pulsarWebServiceUrl)) {
+            pulsarAdminBuilder = PulsarAdmin.builder().serviceHttpUrl(pulsarWebServiceUrl);
+            if (authConfig != null) {
+                if (isNotBlank(authConfig.getClientAuthenticationPlugin())
+                        && isNotBlank(authConfig.getClientAuthenticationParameters())) {
+                    pulsarAdminBuilder.authentication(authConfig.getClientAuthenticationPlugin(),
+                            authConfig.getClientAuthenticationParameters());
+                }
+                if (isNotBlank(authConfig.getTlsTrustCertsFilePath())) {
+                    pulsarAdminBuilder.tlsTrustCertsFilePath(authConfig.getTlsTrustCertsFilePath());
+                }
+                pulsarAdminBuilder.allowTlsInsecureConnection(authConfig.isTlsAllowInsecureConnection());
+                pulsarAdminBuilder.enableTlsHostnameVerification(authConfig.isTlsHostnameVerificationEnable());
+            }
+            return pulsarAdminBuilder.build();
+        }
+        return null;

Review comment:
       since the method throws an exception, it might be worth throwing an exception saying the `pulsarWebServiceUrl` is null.

##########
File path: pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdFunctions.java
##########
@@ -617,6 +617,8 @@ protected void validateFunctionConfigs(FunctionConfig functionConfig) {
         protected String DEPRECATED_brokerServiceUrl;
         @Parameter(names = "--broker-service-url", description = "The URL for Pulsar broker")
         protected String brokerServiceUrl;
+        @Parameter(names = "--web-service-url", description = "The URL for Pulsar web service")
+        protected String webServiceUrl;

Review comment:
       I think we need to make this an optional field for backward compatibility.

##########
File path: pulsar-functions/api-java/pom.xml
##########
@@ -49,6 +49,13 @@
       <scope>compile</scope>
     </dependency>
 
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>pulsar-client-admin-original</artifactId>

Review comment:
       @freeznet Can you move the admin API to a separate module (i.e. move them to a `pulsar-client-admin-api` module)? So we don't need to reference an implementation module in the `api-java` module.

##########
File path: pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/JavaInstanceStarter.java
##########
@@ -132,6 +132,9 @@
     @Parameter(names = "--pending_async_requests", description = "Max pending async requests per instance", required = false)
     public int maxPendingAsyncRequests = 1000;
 
+    @Parameter(names = "--web_serviceurl", description = "Pulsar Web Service Url", required = false)
+    public String webServiceUrl;

Review comment:
       Make this field optional for backward compatibility.

##########
File path: pulsar-functions/localrun/src/main/java/org/apache/pulsar/functions/LocalRunner.java
##########
@@ -135,6 +135,8 @@ public RuntimeEnv convert(String value) {
     protected String stateStorageServiceUrl;
     @Parameter(names = "--brokerServiceUrl", description = "The URL for the Pulsar broker", hidden = true)
     protected String brokerServiceUrl;
+    @Parameter(names = "--webServiceUrl", description = "The URL for the Pulsar web service", hidden = true)
+    protected String webServiceUrl;

Review comment:
       Make this optional for backward compatibility.

##########
File path: pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/RuntimeUtils.java
##########
@@ -355,6 +357,14 @@
 
         args.add("--pulsar_serviceurl");
         args.add(pulsarServiceUrl);
+        if (instanceConfig.getFunctionDetails().getRuntime() == Function.FunctionDetails.Runtime.JAVA) {
+            // TODO: for now only Java function context exposed pulsar admin, so python/go no need to pass this argument
+            // until pulsar admin client enabled in python/go function context.
+            if (pulsarWebServiceUrl != null) {

Review comment:
       we need to add a flag in the function worker config to control whether to expose PulsarAdmin through context. Because the new function worker will add this `--web_serviceurl` to the command line that is not able to recognize by the function instance. So we need to have a flag to allow people to do the following update sequence:
   
   1. Update function worker with exposing pulsar admin disabled.
   2. Update all the functions to the new image that understand `--web_serviceurl`
   3. Update function worker to enable exposing pulsar admin.




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] sijie commented on a change in pull request #9246: [fix #8089] expose PulsarAdmin client through Function Context

Posted by GitBox <gi...@apache.org>.
sijie commented on a change in pull request #9246:
URL: https://github.com/apache/pulsar/pull/9246#discussion_r563436302



##########
File path: pulsar-functions/api-java/pom.xml
##########
@@ -49,6 +49,13 @@
       <scope>compile</scope>
     </dependency>
 
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>pulsar-client-admin-original</artifactId>

Review comment:
       @freeznet I don't think we need to rename the packages at this moment. For this pull request, we can just move the files to different modules. That would be sufficient for now. Changing the API classes is a breaking change. We need to think more carefully about that.




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] freeznet commented on a change in pull request #9246: [fix #8089] expose PulsarAdmin client through Function Context

Posted by GitBox <gi...@apache.org>.
freeznet commented on a change in pull request #9246:
URL: https://github.com/apache/pulsar/pull/9246#discussion_r563733287



##########
File path: pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/RuntimeUtils.java
##########
@@ -355,6 +357,14 @@
 
         args.add("--pulsar_serviceurl");
         args.add(pulsarServiceUrl);
+        if (instanceConfig.getFunctionDetails().getRuntime() == Function.FunctionDetails.Runtime.JAVA) {
+            // TODO: for now only Java function context exposed pulsar admin, so python/go no need to pass this argument
+            // until pulsar admin client enabled in python/go function context.
+            if (pulsarWebServiceUrl != null) {

Review comment:
       I agree, flag added, also add some tests when `exposePulsarAdminClientEnabled=false`




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] lhotari commented on a change in pull request #9246: [fix #8089] expose PulsarAdmin client through Function Context

Posted by GitBox <gi...@apache.org>.
lhotari commented on a change in pull request #9246:
URL: https://github.com/apache/pulsar/pull/9246#discussion_r576115681



##########
File path: pulsar-client-admin-api/pom.xml
##########
@@ -0,0 +1,73 @@
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.pulsar</groupId>
+        <artifactId>pulsar</artifactId>
+        <version>2.8.0-SNAPSHOT</version>
+        <relativePath>..</relativePath>
+    </parent>
+
+    <artifactId>pulsar-client-admin-api</artifactId>
+    <name>Pulsar Client Admin :: API</name>
+
+    <dependencies>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>pulsar-common</artifactId>
+            <version>${project.parent.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>pulsar-client-original</artifactId>
+            <version>${project.parent.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>pulsar-package-core</artifactId>
+            <version>${project.version}</version>
+        </dependency>

Review comment:
       Size of https://hub.docker.com/layers/streamnative/pulsar-all/2.8.0-rc-202102022225/images/sha256-50d6a03312262d5b60efbb29e8c4a3f2245d1317ee25164e18bbd43a0d86113c?context=exploreis 2.91GB , 
   on the previous day, it was 2.25GB:
   https://hub.docker.com/layers/streamnative/pulsar-all/2.8.0-rc-202102012227/images/sha256-04d33735218a612dd53c7963a35bbe9d8c9a0db1625555aa501cfa95821e029f?context=explore
   
   ![image](https://user-images.githubusercontent.com/66864/107939259-282d5c80-6f8f-11eb-8f4f-aa430543bf34.png)
   
   The ≈700MB increase most likely happened after this PR was merged.




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] freeznet commented on pull request #9246: [fix #8089] expose PulsarAdmin client through Function Context

Posted by GitBox <gi...@apache.org>.
freeznet commented on pull request #9246:
URL: https://github.com/apache/pulsar/pull/9246#issuecomment-770393828


   /pulsarbot run-failure-checks


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] freeznet commented on pull request #9246: [fix #8089] expose PulsarAdmin client through Function Context

Posted by GitBox <gi...@apache.org>.
freeznet commented on pull request #9246:
URL: https://github.com/apache/pulsar/pull/9246#issuecomment-770773390


   /pulsarbot run-failure-checks


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] freeznet commented on pull request #9246: [fix #8089] expose PulsarAdmin client through Function Context

Posted by GitBox <gi...@apache.org>.
freeznet commented on pull request #9246:
URL: https://github.com/apache/pulsar/pull/9246#issuecomment-766824752


   @eolivelli @sijie code changed according to your review, PTAL when you have time, thanks


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] eolivelli commented on a change in pull request #9246: [fix #8089] expose PulsarAdmin client through Function Context

Posted by GitBox <gi...@apache.org>.
eolivelli commented on a change in pull request #9246:
URL: https://github.com/apache/pulsar/pull/9246#discussion_r560949520



##########
File path: pulsar-functions/api-java/src/main/java/org/apache/pulsar/functions/api/Context.java
##########
@@ -262,6 +264,21 @@
      */
     String getSecret(String secretName);
 
+    /**
+     * Get the pulsar admin client.
+     *
+     * @return The instance of pulsar admin client
+     */
+    PulsarAdmin getPulsarAdmin();
+
+    /**
+     * Get the pulsar admin client by cluster name.

Review comment:
       can we explain here when it is better to use this method instead of the other ?

##########
File path: pulsar-functions/instance/src/main/java/org/apache/pulsar/functions/instance/ContextImpl.java
##########
@@ -300,6 +304,21 @@ public String getSecret(String secretName) {
         }
     }
 
+    @Override
+    public PulsarAdmin getPulsarAdmin() {
+        return getPulsarAdmin(defaultPulsarCluster);
+    }
+
+    @Override
+    public PulsarAdmin getPulsarAdmin(String clusterName) {
+        PulsarCluster pulsarCluster = externalPulsarClusters.get(clusterName);
+        if (pulsarCluster != null) {
+            return pulsarCluster.getAdminClient();
+        } else {
+            return null;

Review comment:
       shall we throw an error ? maybe reporting the list of known clusters ?
   `
   throw new IllegalArgumentException("PulsarAdmin for cluster "+clusterName+" is not available, only "+extrenalPulsarCluters.keySet())` 
   
   if we do not throw an error, can we log something at warning level ?




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] freeznet commented on a change in pull request #9246: [fix #8089] expose PulsarAdmin client through Function Context

Posted by GitBox <gi...@apache.org>.
freeznet commented on a change in pull request #9246:
URL: https://github.com/apache/pulsar/pull/9246#discussion_r561449955



##########
File path: pulsar-functions/api-java/src/main/java/org/apache/pulsar/functions/api/Context.java
##########
@@ -262,6 +264,21 @@
      */
     String getSecret(String secretName);
 
+    /**
+     * Get the pulsar admin client.
+     *
+     * @return The instance of pulsar admin client
+     */
+    PulsarAdmin getPulsarAdmin();
+
+    /**
+     * Get the pulsar admin client by cluster name.

Review comment:
       yes, just as sijie said, `getPulsarAdmin()` will just get the `default` pulsar admin client, the other one will let user get pulsar admin client if `externalPulsarClusters` is set.

##########
File path: pulsar-functions/instance/src/main/java/org/apache/pulsar/functions/instance/ContextImpl.java
##########
@@ -300,6 +304,21 @@ public String getSecret(String secretName) {
         }
     }
 
+    @Override
+    public PulsarAdmin getPulsarAdmin() {
+        return getPulsarAdmin(defaultPulsarCluster);
+    }
+
+    @Override
+    public PulsarAdmin getPulsarAdmin(String clusterName) {
+        PulsarCluster pulsarCluster = externalPulsarClusters.get(clusterName);
+        if (pulsarCluster != null) {
+            return pulsarCluster.getAdminClient();
+        } else {
+            return null;

Review comment:
       thanks for the review, will add the exception.




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] freeznet edited a comment on pull request #9246: [fix #8089] expose PulsarAdmin client through Function Context

Posted by GitBox <gi...@apache.org>.
freeznet edited a comment on pull request #9246:
URL: https://github.com/apache/pulsar/pull/9246#issuecomment-766824752


   @eolivelli @sijie @nlu90 code changed according to your review, PTAL when you have time, thanks


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] sijie commented on pull request #9246: [fix #8089] expose PulsarAdmin client through Function Context

Posted by GitBox <gi...@apache.org>.
sijie commented on pull request #9246:
URL: https://github.com/apache/pulsar/pull/9246#issuecomment-763941491


   @nlu90 Can you review this since you add the multiple-cluster support there?


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] freeznet commented on pull request #9246: [fix #8089] expose PulsarAdmin client through Function Context

Posted by GitBox <gi...@apache.org>.
freeznet commented on pull request #9246:
URL: https://github.com/apache/pulsar/pull/9246#issuecomment-766824752


   @eolivelli @sijie code changed according to your review, PTAL when you have time, thanks


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] freeznet commented on a change in pull request #9246: [fix #8089] expose PulsarAdmin client through Function Context

Posted by GitBox <gi...@apache.org>.
freeznet commented on a change in pull request #9246:
URL: https://github.com/apache/pulsar/pull/9246#discussion_r563293782



##########
File path: pulsar-functions/api-java/pom.xml
##########
@@ -49,6 +49,13 @@
       <scope>compile</scope>
     </dependency>
 
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>pulsar-client-admin-original</artifactId>

Review comment:
       I have moved apis to module `pulsar-client-admin-api` with package `org.apache.pulsar.client.admin.api`, and also moved the implementation from package `org.apache.pulsar.client.admin.internal` to `org.apache.pulsar.client.admin.impl` to align with pulsar client module. PTAL @sijie if this change is okay, thanks.




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] freeznet removed a comment on pull request #9246: [fix #8089] expose PulsarAdmin client through Function Context

Posted by GitBox <gi...@apache.org>.
freeznet removed a comment on pull request #9246:
URL: https://github.com/apache/pulsar/pull/9246#issuecomment-770587797


   /pulsarbot run-failure-checks


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] freeznet commented on pull request #9246: [fix #8089] expose PulsarAdmin client through Function Context

Posted by GitBox <gi...@apache.org>.
freeznet commented on pull request #9246:
URL: https://github.com/apache/pulsar/pull/9246#issuecomment-770372407


   /pulsarbot run-failure-checks


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] freeznet commented on a change in pull request #9246: [fix #8089] expose PulsarAdmin client through Function Context

Posted by GitBox <gi...@apache.org>.
freeznet commented on a change in pull request #9246:
URL: https://github.com/apache/pulsar/pull/9246#discussion_r561450150



##########
File path: pulsar-functions/instance/src/main/java/org/apache/pulsar/functions/instance/ContextImpl.java
##########
@@ -300,6 +304,21 @@ public String getSecret(String secretName) {
         }
     }
 
+    @Override
+    public PulsarAdmin getPulsarAdmin() {
+        return getPulsarAdmin(defaultPulsarCluster);
+    }
+
+    @Override
+    public PulsarAdmin getPulsarAdmin(String clusterName) {
+        PulsarCluster pulsarCluster = externalPulsarClusters.get(clusterName);
+        if (pulsarCluster != null) {
+            return pulsarCluster.getAdminClient();
+        } else {
+            return null;

Review comment:
       thanks for the review, will add the exception.




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] freeznet commented on pull request #9246: [fix #8089] expose PulsarAdmin client through Function Context

Posted by GitBox <gi...@apache.org>.
freeznet commented on pull request #9246:
URL: https://github.com/apache/pulsar/pull/9246#issuecomment-768680533


   /pulsarbot run-failure-checks


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] sijie commented on a change in pull request #9246: [fix #8089] expose PulsarAdmin client through Function Context

Posted by GitBox <gi...@apache.org>.
sijie commented on a change in pull request #9246:
URL: https://github.com/apache/pulsar/pull/9246#discussion_r561137512



##########
File path: pulsar-functions/api-java/src/main/java/org/apache/pulsar/functions/api/Context.java
##########
@@ -262,6 +264,21 @@
      */
     String getSecret(String secretName);
 
+    /**
+     * Get the pulsar admin client.
+     *
+     * @return The instance of pulsar admin client
+     */
+    PulsarAdmin getPulsarAdmin();
+
+    /**
+     * Get the pulsar admin client by cluster name.

Review comment:
       Pulsar recently adds support for multiple clusters, i.e. input topics from cluster A and output topics from cluster B. This method just provides the same support for admin calls.




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] freeznet commented on pull request #9246: [fix #8089] expose PulsarAdmin client through Function Context

Posted by GitBox <gi...@apache.org>.
freeznet commented on pull request #9246:
URL: https://github.com/apache/pulsar/pull/9246#issuecomment-771237141


   /pulsarbot run-failure-checks


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] nlu90 commented on pull request #9246: [fix #8089] expose PulsarAdmin client through Function Context

Posted by GitBox <gi...@apache.org>.
nlu90 commented on pull request #9246:
URL: https://github.com/apache/pulsar/pull/9246#issuecomment-775491410


   sorry for the late reply. @sijie 
   
   I just notice this change and am wondering the necessity of exposing the whole admin client from functions to users. Maybe we can have some discussion when you are available


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] sijie merged pull request #9246: [fix #8089] expose PulsarAdmin client through Function Context

Posted by GitBox <gi...@apache.org>.
sijie merged pull request #9246:
URL: https://github.com/apache/pulsar/pull/9246


   


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] sijie merged pull request #9246: [fix #8089] expose PulsarAdmin client through Function Context

Posted by GitBox <gi...@apache.org>.
sijie merged pull request #9246:
URL: https://github.com/apache/pulsar/pull/9246


   


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org