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
This commit is contained in:
Andrew Rumble 2025-02-21 10:08:13 +00:00 committed by Copybot
parent fe878a88d1
commit 59b708e3f7
2 changed files with 9 additions and 2 deletions

View file

@ -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 {

View file

@ -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: {