diff --git a/services/clsi/app.js b/services/clsi/app.js index f132eb00f6..b33f77140f 100644 --- a/services/clsi/app.js +++ b/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 { diff --git a/services/clsi/config/settings.defaults.js b/services/clsi/config/settings.defaults.js index 21fe82e533..e32815ae44 100644 --- a/services/clsi/config/settings.defaults.js +++ b/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: {