This is an automated email from the ASF dual-hosted git repository.

zhaijia pushed a commit to branch branch-2.5
in repository https://gitbox.apache.org/repos/asf/pulsar.git

commit 0dfb4822b3298415c73a60add8da61df638592b9
Author: Chris Bartholomew <[email protected]>
AuthorDate: Fri May 8 22:16:57 2020 -0400

    [function] Function endpoint admin/v3/functions/{tenant}/{namespace} always 
returns 404 (#6767)
    
    Fix #6839
    ### Motivation
    
    The V3 endpoint that returns a list of all functions in a namespace always 
returns 404. The V2 version of the endpoint returns the actual list of 
functions in the namespace. It looks like during the switch from V2 to V3, the 
implementation for the endpoint was missed. This endpoint is part of the 
current API 
[documentation](https://pulsar.apache.org/functions-rest-api/?version=2.5.0#operation/listFunctions),
 so I don't think it was removed intentionally.
    
    This endpoint is also used by the pulsar-admin command, so that always 
returns 404:
    
    ```
    pulsar-admin functions list --tenant chris-kafkaesque-io --namespace 
local-useast2-aws
    HTTP 404 Not Found
    
    Reason: HTTP 404 Not Found
    ```
    
    ### Modifications
    
    I have added the endpoint to `FunctionsApiV3Resource.java`. It is 
essentially a clone of the V2 version.
    
    ### Verifying this change
    
    This is a pretty small change. I have confirmed that the V3 version of the 
endpoint now returns the same list of functions as the V2 version. I have also 
confirmed that the pulsar-admin command now works:
    
    ```
    bin/pulsar-admin functions list --tenant chris-kafkaesque-io --namespace TTL
    23:45:10.763 [main] INFO  org.apache.pulsar.common.util.SecurityUtility - 
Found and Instantiated Bouncy Castle provider in classpath BC
    "exclaim"
    "pulsar-functions-0.1"
    ```
    
    (cherry picked from commit 714a776c124f5afff86f6df87675f3452e6dd207)
---
 .../functions/worker/rest/api/v3/FunctionsApiV3Resource.java      | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git 
a/pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/rest/api/v3/FunctionsApiV3Resource.java
 
b/pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/rest/api/v3/FunctionsApiV3Resource.java
index 203ae62..ee6b4f6 100644
--- 
a/pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/rest/api/v3/FunctionsApiV3Resource.java
+++ 
b/pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/rest/api/v3/FunctionsApiV3Resource.java
@@ -109,6 +109,14 @@ public class FunctionsApiV3Resource extends 
FunctionApiResource {
     }
 
     @GET
+    @Produces(MediaType.APPLICATION_JSON)
+    @Path("/{tenant}/{namespace}")
+    public List<String> listSources(final @PathParam("tenant") String tenant,
+                                    final @PathParam("namespace") String 
namespace) {
+        return functions.listFunctions(tenant, namespace, clientAppId(), 
clientAuthData());
+    }
+
+    @GET
     @ApiOperation(
             value = "Displays the status of a Pulsar Function instance",
             response = 
FunctionStatus.FunctionInstanceStatus.FunctionInstanceStatusData.class

Reply via email to