Эх сурвалжийг харах

Allow draining to be prevented in CLSI agent

Co-authored-by: Brian Gough <brian.gough@overleaf.com>
Co-authored-by: Christopher Hoskin <mans0954@users.noreply.github.com>
GitOrigin-RevId: f55de7783cb1c14108eb347eebb74ec329180000
Andrew Rumble 1 жил өмнө
parent
commit
59b708e3f7

+ 5 - 2
services/clsi/app.js

@@ -343,7 +343,10 @@ const loadTcpServer = net.createServer(function (socket) {
     const freeLoadPercentage = Math.round(
       (freeLoad / availableWorkingCpus) * 100
     )
-    if (freeLoadPercentage <= 0) {
+    if (
+      Settings.internal.load_balancer_agent.allow_maintenance &&
+      freeLoadPercentage <= 0
+    ) {
       // When its 0 the server is set to drain implicitly.
       // Drain will move new projects to different servers.
       // Drain will keep existing projects assigned to the same server.
@@ -351,7 +354,7 @@ const loadTcpServer = net.createServer(function (socket) {
       socket.write(`maint, 0%\n`, 'ASCII')
     } else {
       // Ready will cancel the maint state.
-      socket.write(`up, ready, ${freeLoadPercentage}%\n`, 'ASCII')
+      socket.write(`up, ready, ${Math.max(freeLoadPercentage, 1)}%\n`, 'ASCII')
     }
     socket.end()
   } else {

+ 4 - 0
services/clsi/config/settings.defaults.js

@@ -37,6 +37,10 @@ module.exports = {
       report_load: process.env.LOAD_BALANCER_AGENT_REPORT_LOAD !== 'false',
       load_port: 3048,
       local_port: 3049,
+      allow_maintenance:
+        (
+          process.env.LOAD_BALANCER_AGENT_ALLOW_MAINTENANCE ?? ''
+        ).toLowerCase() !== 'false',
     },
   },
   apis: {