Просмотр исходного кода

[git-bridge] Downgrade `info` logs to `debug` (#32470)

* [git-bridge] Downgrade `info` logs to `debug`

Moving most `info` logs to `debug` to reduce log noise.

GitOrigin-RevId: 21f8d11ba950078b5e3a88a245e8ed68f2548141
Miguel Serrano 4 месяцев назад
Родитель
Сommit
251ccbf1ad

+ 1 - 1
services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/application/GitBridgeApp.java

@@ -83,7 +83,7 @@ public class GitBridgeApp implements Runnable {
   }
 
   private void loadConfigFile() throws ConfigFileException, IOException {
-    Log.info("Loading config file at path: " + configFilePath);
+    Log.debug("Loading config file at path: " + configFilePath);
     config = new Config(configFilePath);
   }
 

+ 4 - 4
services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/bridge/Bridge.java

@@ -162,7 +162,7 @@ public class Bridge {
       SwapStore swapStore,
       SnapshotApi snapshotApi) {
     ProjectLock lock =
-        new ProjectLockImpl((int threads) -> Log.info("Waiting for " + threads + " projects..."));
+        new ProjectLockImpl((int threads) -> Log.debug("Waiting for " + threads + " projects..."));
     return new Bridge(
         config,
         lock,
@@ -261,7 +261,7 @@ public class Bridge {
    * the schema.
    */
   public void checkDB() {
-    Log.info("Checking DB");
+    Log.debug("Checking DB");
     File rootDir = repoStore.getRootDirectory();
     for (File f : rootDir.listFiles()) {
       if (f.getName().equals(".wlgb")) {
@@ -342,7 +342,7 @@ public class Bridge {
     ProjectState state = dbStore.getProjectState(projectName);
     switch (state) {
       case NOT_PRESENT:
-        Log.info("[{}] Repo not present", projectName);
+        Log.debug("[{}] Repo not present", projectName);
         repo = repoStore.initRepo(projectName);
         break;
       case SWAPPED:
@@ -391,7 +391,7 @@ public class Bridge {
           CannotAcquireLockException {
     Log.debug("[{}] pushing to Overleaf", projectName);
     try (LockGuard __ = lock.lockGuard(projectName)) {
-      Log.info("[{}] got project lock", projectName);
+      Log.debug("[{}] got project lock", projectName);
       pushCritical(oauth2, projectName, directoryContents, oldDirectoryContents);
     } catch (SevereSnapshotPostException e) {
       Log.warn("[" + projectName + "] Failed to put to Overleaf", e);

+ 4 - 4
services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/bridge/gc/GcJobImpl.java

@@ -58,13 +58,13 @@ public class GcJobImpl implements GcJob {
 
   @Override
   public void start() {
-    Log.info("Starting GC job to run every [{}] ms", intervalMs);
+    Log.debug("Starting GC job to run every [{}] ms", intervalMs);
     timer.scheduleAtFixedRate(TimerUtils.makeTimerTask(this::doGC), intervalMs, intervalMs);
   }
 
   @Override
   public void stop() {
-    Log.info("Stopping GC job");
+    Log.debug("Stopping GC job");
     timer.cancel();
   }
 
@@ -100,7 +100,7 @@ public class GcJobImpl implements GcJob {
   }
 
   private void doGC() {
-    Log.info("GC job running");
+    Log.debug("GC job running");
     int numGcs = 0;
     preGc.get().run();
     for (Iterator<String> it = gcQueue.iterator(); it.hasNext(); it.remove(), ++numGcs) {
@@ -118,7 +118,7 @@ public class GcJobImpl implements GcJob {
         Log.warn("[{}] Cannot acquire project lock, skipping GC", proj);
       }
     }
-    Log.info("GC job finished, num gcs: {}", numGcs);
+    Log.debug("GC job finished, num gcs: {}", numGcs);
     jobWaitersLock.lock();
     try {
       jobWaiters.forEach(w -> w.complete(null));

+ 1 - 1
services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/bridge/swap/job/SwapJobConfig.java

@@ -53,7 +53,7 @@ public class SwapJobConfig {
   public SwapJob.CompressionMethod getCompressionMethod() {
     CompressionMethod result = SwapJob.stringToCompressionMethod(compressionMethod);
     if (result == null) {
-      Log.info(
+      Log.warn(
           "SwapJobConfig: un-supported compressionMethod '{}', default to 'bzip2'",
           compressionMethod);
       result = CompressionMethod.Bzip2;

+ 2 - 2
services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/bridge/swap/job/SwapJobImpl.java

@@ -178,7 +178,7 @@ public class SwapJobImpl implements SwapJob {
   @Override
   public void evict(String projName) throws IOException {
     Preconditions.checkNotNull(projName, "projName was null");
-    Log.info("Evicting project: {}", projName);
+    Log.debug("Evicting project: {}", projName);
     try (LockGuard __ = lock.lockGuard(projName)) {
       try {
         repoStore.gcProject(projName);
@@ -199,7 +199,7 @@ public class SwapJobImpl implements SwapJob {
       Log.warn("[{}] Cannot acquire project lock, skipping swap", projName);
       return;
     }
-    Log.info("Evicted project: {}", projName);
+    Log.debug("Evicted project: {}", projName);
   }
 
   private InputStream getBlobStream(String projName, long[] sizePtr) throws IOException {

+ 9 - 9
services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/server/Oauth2Filter.java

@@ -65,7 +65,7 @@ public class Oauth2Filter implements Filter {
     String requestUri = request.getRequestURI();
 
     if (requestUri.startsWith("/project")) {
-      Log.info("[{}] Invalid request URI", requestUri);
+      Log.debug("[{}] Invalid request URI", requestUri);
       sendResponse(
           response, 404, Arrays.asList("Invalid Project ID (must not have a '/project' prefix)"));
       return;
@@ -157,7 +157,7 @@ public class Oauth2Filter implements Filter {
   private void handleLinkSharingId(
       String projectId, String username, HttpServletRequest request, HttpServletResponse response)
       throws IOException {
-    Log.info("[{}] Bad project id, User '{}' ip={}", projectId, username, getClientIp(request));
+    Log.debug("[{}] Bad project id, User '{}' ip={}", projectId, username, getClientIp(request));
     sendResponse(
         response,
         404,
@@ -174,7 +174,7 @@ public class Oauth2Filter implements Filter {
   private void handleBadProjectId(
       String projectId, String username, HttpServletRequest request, HttpServletResponse response)
       throws IOException {
-    Log.info("[{}] Bad project id, User '{}' ip={}", projectId, username, getClientIp(request));
+    Log.debug("[{}] Bad project id, User '{}' ip={}", projectId, username, getClientIp(request));
     sendResponse(
         response,
         404,
@@ -188,7 +188,7 @@ public class Oauth2Filter implements Filter {
   private void handleRateLimit(
       String projectId, String username, HttpServletRequest request, HttpServletResponse response)
       throws IOException {
-    Log.info("[{}] Rate limit, User '{}' ip={}", projectId, username, getClientIp(request));
+    Log.debug("[{}] Rate limit, User '{}' ip={}", projectId, username, getClientIp(request));
     sendResponse(
         response, 429, Arrays.asList("Rate limit exceeded. Please wait and try again later."));
   }
@@ -196,7 +196,7 @@ public class Oauth2Filter implements Filter {
   private void handleNeedAuthorization(
       String projectId, String username, HttpServletRequest request, HttpServletResponse response)
       throws IOException {
-    Log.info("[{}] Unauthorized, User '{}' ip={}", projectId, username, getClientIp(request));
+    Log.debug("[{}] Unauthorized, User '{}' ip={}", projectId, username, getClientIp(request));
     response.setHeader("WWW-Authenticate", "Basic realm=\"Git Bridge\"");
     if (this.isUserPasswordEnabled) {
       sendResponse(
@@ -226,7 +226,7 @@ public class Oauth2Filter implements Filter {
   private void handleBadAccessToken(
       String projectId, HttpServletRequest request, HttpServletResponse response)
       throws IOException {
-    Log.info("[{}] Bad access token, ip={}", projectId, getClientIp(request));
+    Log.debug("[{}] Bad access token, ip={}", projectId, getClientIp(request));
     sendResponse(
         response,
         401,
@@ -254,7 +254,7 @@ public class Oauth2Filter implements Filter {
   private void handleUnknownOauthServerError(
       String projectId, int statusCode, HttpServletRequest request, HttpServletResponse response)
       throws IOException {
-    Log.info(
+    Log.debug(
         "[{}] OAuth server error, statusCode={}, ip={}",
         projectId,
         statusCode,
@@ -266,14 +266,14 @@ public class Oauth2Filter implements Filter {
       String projectId, String username, HttpServletRequest request, HttpServletResponse response)
       throws IOException {
     if (username.contains("@")) {
-      Log.info("[{}] Password authentication deprecated, ip={}", projectId, getClientIp(request));
+      Log.debug("[{}] Password authentication deprecated, ip={}", projectId, getClientIp(request));
       sendResponse(
           response,
           403,
           Arrays.asList(
               "Overleaf now only supports Git authentication tokens to access git. See: https://www.overleaf.com/learn/how-to/Git_integration_authentication_tokens"));
     } else {
-      Log.info("[{}] Wrong git URL format, ip={}", projectId, getClientIp(request));
+      Log.debug("[{}] Wrong git URL format, ip={}", projectId, getClientIp(request));
       sendResponse(
           response,
           403,