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

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


The following commit(s) were added to refs/heads/master by this push:
     new f6cf96faea Forward auth token for logger APIs from controller to other 
controllers and brokers (#10590)
f6cf96faea is described below

commit f6cf96faea81f1d7f94b12937eddbe6dd0454cf0
Author: Xiang Fu <xiangfu.1...@gmail.com>
AuthorDate: Tue Apr 11 23:45:11 2023 -0700

    Forward auth token for logger APIs from controller to other controllers and 
brokers (#10590)
---
 .../controller/api/resources/PinotControllerLogger.java | 17 ++++++++++++++---
 .../java/org/apache/pinot/tools/AuthQuickstart.java     |  5 +++++
 2 files changed, 19 insertions(+), 3 deletions(-)

diff --git 
a/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotControllerLogger.java
 
b/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotControllerLogger.java
index ae9c5db321..d57746b462 100644
--- 
a/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotControllerLogger.java
+++ 
b/pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotControllerLogger.java
@@ -36,6 +36,7 @@ import java.util.Map;
 import java.util.Set;
 import javax.inject.Inject;
 import javax.ws.rs.GET;
+import javax.ws.rs.HeaderParam;
 import javax.ws.rs.PUT;
 import javax.ws.rs.Path;
 import javax.ws.rs.PathParam;
@@ -145,7 +146,8 @@ public class PinotControllerLogger {
   @Path("/loggers/instances")
   @Produces(MediaType.APPLICATION_JSON)
   @ApiOperation(value = "Collect log files from all the instances")
-  public Map<String, Set<String>> getLogFilesFromAllInstances() {
+  public Map<String, Set<String>> getLogFilesFromAllInstances(
+      @HeaderParam(HttpHeaders.AUTHORIZATION) String authorization) {
     if (_logFileServer == null || _logFileServer instanceof 
DummyLogFileServer) {
       throw new WebApplicationException("Root directory doesn't exist", 
Response.Status.INTERNAL_SERVER_ERROR);
     }
@@ -154,7 +156,7 @@ public class PinotControllerLogger {
     onlineInstanceList.forEach(
         instance -> {
           try {
-            instancesToLogFilesMap.put(instance, 
getLogFilesFromInstance(instance));
+            instancesToLogFilesMap.put(instance, 
getLogFilesFromInstance(authorization, instance));
           } catch (Exception e) {
             // Skip the instance for any exception.
           }
@@ -167,10 +169,15 @@ public class PinotControllerLogger {
   @Produces(MediaType.APPLICATION_JSON)
   @ApiOperation(value = "Collect log files from a given instance")
   public Set<String> getLogFilesFromInstance(
+      @HeaderParam(HttpHeaders.AUTHORIZATION) String authorization,
       @ApiParam(value = "Instance Name", required = true) 
@PathParam("instanceName") String instanceName) {
     try {
       URI uri = new URI(getInstanceBaseUri(instanceName) + "/loggers/files");
-      SimpleHttpResponse simpleHttpResponse = 
_fileUploadDownloadClient.getHttpClient().sendGetRequest(uri);
+      Map<String, String> headers = new HashMap<>();
+      if (authorization != null) {
+        headers.put(HttpHeaders.AUTHORIZATION, authorization);
+      }
+      SimpleHttpResponse simpleHttpResponse = 
_fileUploadDownloadClient.getHttpClient().sendGetRequest(uri, headers);
       if (simpleHttpResponse.getStatusCode() >= 400) {
         throw new WebApplicationException("Failed to fetch logs from instance 
name: " + instanceName,
             
Response.Status.fromStatusCode(simpleHttpResponse.getStatusCode()));
@@ -189,6 +196,7 @@ public class PinotControllerLogger {
   @Authenticate(AccessType.DELETE)
   @ApiOperation(value = "Download a log file from a given instance")
   public Response downloadLogFileFromInstance(
+      @HeaderParam(HttpHeaders.AUTHORIZATION) String authorization,
       @ApiParam(value = "Instance Name", required = true) 
@PathParam("instanceName") String instanceName,
       @ApiParam(value = "Log file path", required = true) 
@QueryParam("filePath") String filePath,
       @Context Map<String, String> headers) {
@@ -201,6 +209,9 @@ public class PinotControllerLogger {
           requestBuilder.addHeader(header.getKey(), header.getValue());
         }
       }
+      if (authorization != null) {
+        requestBuilder.addHeader(HttpHeaders.AUTHORIZATION, authorization);
+      }
       CloseableHttpResponse httpResponse = 
_fileUploadDownloadClient.getHttpClient().execute(requestBuilder.build());
       if (httpResponse.getStatusLine().getStatusCode() >= 400) {
         throw new 
WebApplicationException(IOUtils.toString(httpResponse.getEntity().getContent(), 
"UTF-8"),
diff --git 
a/pinot-tools/src/main/java/org/apache/pinot/tools/AuthQuickstart.java 
b/pinot-tools/src/main/java/org/apache/pinot/tools/AuthQuickstart.java
index e4eaa89715..59d4b3f9f0 100644
--- a/pinot-tools/src/main/java/org/apache/pinot/tools/AuthQuickstart.java
+++ b/pinot-tools/src/main/java/org/apache/pinot/tools/AuthQuickstart.java
@@ -74,6 +74,11 @@ public class AuthQuickstart extends Quickstart {
     properties.put("segment.fetcher.auth.token", "Basic 
YWRtaW46dmVyeXNlY3JldA==");
     properties.put("task.auth.token", "Basic YWRtaW46dmVyeXNlY3JldA==");
 
+    // loggers
+    properties.put("pinot.controller.logger.root.dir", "logs");
+    properties.put("pinot.broker.logger.root.dir", "logs");
+    properties.put("pinot.server.logger.root.dir", "logs");
+    properties.put("pinot.minion.logger.root.dir", "logs");
     return properties;
   }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org
For additional commands, e-mail: commits-h...@pinot.apache.org

Reply via email to