From a239b70bfca2a4ca802e154d30b0c7070f2c660f Mon Sep 17 00:00:00 2001 From: Simon Detheridge Date: Mon, 28 Jun 2021 17:00:52 +0100 Subject: [PATCH 1/2] Revert change to make Jetty idle timeout configurable --- .../git-bridge/conf/envsubst_template.json | 2 -- services/git-bridge/conf/example_config.json | 2 -- services/git-bridge/conf/local.json | 2 -- .../wlgitbridge/application/config/Config.java | 18 ------------------ .../ic/wlgitbridge/server/GitBridgeServer.java | 9 +-------- .../WLGitBridgeIntegrationTest.java | 2 -- .../application/config/ConfigTest.java | 8 -------- .../ac/ic/wlgitbridge/bridge/BridgeTest.java | 2 -- 8 files changed, 1 insertion(+), 44 deletions(-) diff --git a/services/git-bridge/conf/envsubst_template.json b/services/git-bridge/conf/envsubst_template.json index df03c9939a..ea0d87adbc 100644 --- a/services/git-bridge/conf/envsubst_template.json +++ b/services/git-bridge/conf/envsubst_template.json @@ -1,7 +1,5 @@ { "port": ${GIT_BRIDGE_PORT:-8000}, - "bindIp": "${GIT_BRIDGE_BIND_IP:-0.0.0.0}", - "idleTimeout": ${GIT_BRIDGE_IDLE_TIMEOUT:-600000}, "rootGitDirectory": "${GIT_BRIDGE_ROOT_DIR:-/tmp/wlgb}", "apiBaseUrl": "${GIT_BRIDGE_API_BASE_URL:-https://localhost/api/v0}", "postbackBaseUrl": "${GIT_BRIDGE_POSTBACK_BASE_URL:-https://localhost}", diff --git a/services/git-bridge/conf/example_config.json b/services/git-bridge/conf/example_config.json index 3972be2cb9..bcf25e7be9 100644 --- a/services/git-bridge/conf/example_config.json +++ b/services/git-bridge/conf/example_config.json @@ -1,7 +1,5 @@ { "port": 8080, - "bindIp": "127.0.0.1", - "idleTimeout": 60000, "rootGitDirectory": "/tmp/wlgb", "apiBaseUrl": "https://localhost/api/v0", "postbackBaseUrl": "https://localhost", diff --git a/services/git-bridge/conf/local.json b/services/git-bridge/conf/local.json index 73121ce6ef..0b2e3e1241 100644 --- a/services/git-bridge/conf/local.json +++ b/services/git-bridge/conf/local.json @@ -1,7 +1,5 @@ { "port": 8000, - "bindIp": "0.0.0.0", - "idleTimeout": 600000, "rootGitDirectory": "/tmp/wlgb", "apiBaseUrl": "http://v2.overleaf.test:4000/api/v0", "postbackBaseUrl": "http://git-bridge:8000", diff --git a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/application/config/Config.java b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/application/config/Config.java index 8dbef10b23..527e2ed714 100644 --- a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/application/config/Config.java +++ b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/application/config/Config.java @@ -24,8 +24,6 @@ public class Config implements JSONSource { static Config asSanitised(Config config) { return new Config( config.port, - config.bindIp, - config.idleTimeout, config.rootGitDirectory, config.apiBaseURL, config.postbackURL, @@ -39,8 +37,6 @@ public class Config implements JSONSource { } private int port; - private String bindIp; - private int idleTimeout; private String rootGitDirectory; private String apiBaseURL; private String postbackURL; @@ -68,8 +64,6 @@ public class Config implements JSONSource { public Config( int port, - String bindIp, - int idleTimeout, String rootGitDirectory, String apiBaseURL, String postbackURL, @@ -81,8 +75,6 @@ public class Config implements JSONSource { int sqliteHeapLimitBytes ) { this.port = port; - this.bindIp = bindIp; - this.idleTimeout = idleTimeout; this.rootGitDirectory = rootGitDirectory; this.apiBaseURL = apiBaseURL; this.postbackURL = postbackURL; @@ -98,8 +90,6 @@ public class Config implements JSONSource { public void fromJSON(JsonElement json) { JsonObject configObject = json.getAsJsonObject(); port = getElement(configObject, "port").getAsInt(); - bindIp = getElement(configObject, "bindIp").getAsString(); - idleTimeout = getElement(configObject, "idleTimeout").getAsInt(); rootGitDirectory = getElement( configObject, "rootGitDirectory" @@ -141,14 +131,6 @@ public class Config implements JSONSource { return port; } - public String getBindIp() { - return bindIp; - } - - public int getIdleTimeout() { - return idleTimeout; - } - public String getRootGitDirectory() { return rootGitDirectory; } diff --git a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/server/GitBridgeServer.java b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/server/GitBridgeServer.java index 312e3648b9..254b9a0c59 100644 --- a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/server/GitBridgeServer.java +++ b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/server/GitBridgeServer.java @@ -2,7 +2,6 @@ package uk.ac.ic.wlgitbridge.server; import org.eclipse.jetty.server.Handler; import org.eclipse.jetty.server.Server; -import org.eclipse.jetty.server.ServerConnector; import org.eclipse.jetty.server.handler.*; import org.eclipse.jetty.servlet.FilterHolder; import org.eclipse.jetty.servlet.ServletContextHandler; @@ -73,7 +72,7 @@ public class GitBridgeServer { swapStore, snapshotApi ); - jettyServer = new Server(); + jettyServer = new Server(port); configureJettyServer(config, repoStore, snapshotApi); apiBaseURL = config.getAPIBaseURL(); SnapshotAPIRequest.setBaseURL(apiBaseURL); @@ -115,12 +114,6 @@ public class GitBridgeServer { RepoStore repoStore, SnapshotApi snapshotApi ) throws ServletException { - ServerConnector connector = new ServerConnector(this.jettyServer); - connector.setPort(config.getPort()); - connector.setHost(config.getBindIp()); - connector.setIdleTimeout(config.getIdleTimeout()); - this.jettyServer.addConnector(connector); - HandlerCollection handlers = new HandlerList(); handlers.addHandler(initApiHandler()); handlers.addHandler(initBaseHandler()); diff --git a/services/git-bridge/src/test/java/uk/ac/ic/wlgitbridge/application/WLGitBridgeIntegrationTest.java b/services/git-bridge/src/test/java/uk/ac/ic/wlgitbridge/application/WLGitBridgeIntegrationTest.java index 6eaa776562..50e8ef674e 100644 --- a/services/git-bridge/src/test/java/uk/ac/ic/wlgitbridge/application/WLGitBridgeIntegrationTest.java +++ b/services/git-bridge/src/test/java/uk/ac/ic/wlgitbridge/application/WLGitBridgeIntegrationTest.java @@ -1063,8 +1063,6 @@ public class WLGitBridgeIntegrationTest { String cfgStr = "{\n" + " \"port\": " + port + ",\n" + - " \"bindIp\": \"127.0.0.1\",\n" + - " \"idleTimeout\": 30000,\n" + " \"rootGitDirectory\": \"" + wlgb.getAbsolutePath() + "\",\n" + diff --git a/services/git-bridge/src/test/java/uk/ac/ic/wlgitbridge/application/config/ConfigTest.java b/services/git-bridge/src/test/java/uk/ac/ic/wlgitbridge/application/config/ConfigTest.java index 02d70def0e..e6036fbf94 100644 --- a/services/git-bridge/src/test/java/uk/ac/ic/wlgitbridge/application/config/ConfigTest.java +++ b/services/git-bridge/src/test/java/uk/ac/ic/wlgitbridge/application/config/ConfigTest.java @@ -16,8 +16,6 @@ public class ConfigTest { public void testConstructWithOauth() { Reader reader = new StringReader("{\n" + " \"port\": 80,\n" + - " \"bindIp\": \"127.0.0.1\",\n" + - " \"idleTimeout\": 30000,\n" + " \"rootGitDirectory\": \"/var/wlgb/git\",\n" + " \"apiBaseUrl\": \"http://127.0.0.1:60000/api/v0\",\n" + " \"postbackBaseUrl\": \"http://127.0.0.1\",\n" + @@ -44,8 +42,6 @@ public class ConfigTest { public void testConstructWithoutOauth() { Reader reader = new StringReader("{\n" + " \"port\": 80,\n" + - " \"bindIp\": \"127.0.0.1\",\n" + - " \"idleTimeout\": 30000,\n" + " \"rootGitDirectory\": \"/var/wlgb/git\",\n" + " \"apiBaseUrl\": \"http://127.0.0.1:60000/api/v0\",\n" + " \"postbackBaseUrl\": \"http://127.0.0.1\",\n" + @@ -66,8 +62,6 @@ public class ConfigTest { public void asSanitised() throws Exception { Reader reader = new StringReader("{\n" + " \"port\": 80,\n" + - " \"bindIp\": \"127.0.0.1\",\n" + - " \"idleTimeout\": 30000,\n" + " \"rootGitDirectory\": \"/var/wlgb/git\",\n" + " \"apiBaseUrl\": \"http://127.0.0.1:60000/api/v0\",\n" + " \"postbackBaseUrl\": \"http://127.0.0.1\",\n" + @@ -81,8 +75,6 @@ public class ConfigTest { Config config = new Config(reader); String expected = "{\n" + " \"port\": 80,\n" + - " \"bindIp\": \"127.0.0.1\",\n" + - " \"idleTimeout\": 30000,\n" + " \"rootGitDirectory\": \"/var/wlgb/git\",\n" + " \"apiBaseURL\": \"http://127.0.0.1:60000/api/v0/\",\n" + " \"postbackURL\": \"http://127.0.0.1/\",\n" + diff --git a/services/git-bridge/src/test/java/uk/ac/ic/wlgitbridge/bridge/BridgeTest.java b/services/git-bridge/src/test/java/uk/ac/ic/wlgitbridge/bridge/BridgeTest.java index 9026973d49..8d51fb862e 100644 --- a/services/git-bridge/src/test/java/uk/ac/ic/wlgitbridge/bridge/BridgeTest.java +++ b/services/git-bridge/src/test/java/uk/ac/ic/wlgitbridge/bridge/BridgeTest.java @@ -53,8 +53,6 @@ public class BridgeTest { gcJob = mock(GcJob.class); bridge = new Bridge( new Config( - 0, - "", 0, "", "", From 4c11b69167dd8fd10d42558a809e4309f4e1e25b Mon Sep 17 00:00:00 2001 From: Simon Detheridge Date: Mon, 28 Jun 2021 17:01:43 +0100 Subject: [PATCH 2/2] Revert "Merge pull request #107 from overleaf/sk-upgrade-jetty-2106" This reverts commit f13d8a990a927f5983442ffce00ff009cdc0e8ab, reversing changes made to cb3ba256b7b27e424616d7bc67b73385fef55be8. --- services/git-bridge/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/git-bridge/pom.xml b/services/git-bridge/pom.xml index 4aea908220..2a11cff9ce 100644 --- a/services/git-bridge/pom.xml +++ b/services/git-bridge/pom.xml @@ -76,13 +76,13 @@ org.eclipse.jetty jetty-servlet - 9.4.38.v20210224 + 9.4.8.v20171121 org.eclipse.jetty jetty-server - 9.4.38.v20210224 + 9.4.8.v20171121