From 255393ead7bcdba6ef4c9fd751a549759310b445 Mon Sep 17 00:00:00 2001 From: Jakob Ackermann Date: Thu, 26 Aug 2021 14:02:09 +0200 Subject: [PATCH] Merge pull request #4890 from overleaf/jpa-clsi-maint [clsi] put server into maintenance mode when reaching zero capacity GitOrigin-RevId: d1af260a3bfba7852519b3bc369a6747e79f3b18 --- services/clsi/app.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/services/clsi/app.js b/services/clsi/app.js index 3f0548d59c..b1b3b2004b 100644 --- a/services/clsi/app.js +++ b/services/clsi/app.js @@ -330,11 +330,19 @@ const loadTcpServer = net.createServer(function (socket) { } const freeLoad = availableWorkingCpus - currentLoad - let freeLoadPercentage = Math.round((freeLoad / availableWorkingCpus) * 100) + const freeLoadPercentage = Math.round( + (freeLoad / availableWorkingCpus) * 100 + ) if (freeLoadPercentage <= 0) { - freeLoadPercentage = 0 // when its 0 the server is set to drain and will move projects to different servers + // 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. + // Maint will more existing and new projects to different servers. + socket.write(`maint, 0%\n`, 'ASCII') + } else { + // Ready will cancel the maint state. + socket.write(`up, ready, ${freeLoadPercentage}%\n`, 'ASCII') } - socket.write(`up, ${freeLoadPercentage}%\n`, 'ASCII') return socket.end() } else { socket.write(`${STATE}\n`, 'ASCII')