srkukarni commented on a change in pull request #7509:
URL: https://github.com/apache/pulsar/pull/7509#discussion_r453337435



##########
File path: 
pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/rest/api/FunctionsImpl.java
##########
@@ -686,10 +686,33 @@ public void updateFunctionOnWorkerLeader(final String 
tenant,
         }
 
         // Redirect if we are not the leader
+        boolean shouldRedirect = false;
         if (!worker().getLeaderService().isLeader()) {
             WorkerInfo workerInfo = 
worker().getMembershipManager().getLeader();
-            URI redirect = 
UriBuilder.fromUri(uri).host(workerInfo.getWorkerHostname()).port(workerInfo.getPort()).build();
-            throw new 
WebApplicationException(Response.temporaryRedirect(redirect).build());
+            // there might be a delay between when the leader service for this 
worker gets triggered "becomeActive"

Review comment:
       I think we should adopt more simple workflow. 
   1. LeaderService.isLeader() is set only after we have fully become leader.
   2. If we are leader, do the request ourselves
   3. else re-direct to the leader
   There will be a case that we might redirect to a leader who is not ready. In 
that case just return error to the user asking him to retry again is perfectly 
valid.




----------------------------------------------------------------
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:
us...@infra.apache.org


Reply via email to