Don't log invalid cgroup memory limits

This commit is contained in:
Henry Mercer 2023-09-27 13:56:20 +01:00
parent 27cb1e1de5
commit 378bbcd274
3 changed files with 15 additions and 1 deletions

5
lib/util.js generated
View file

@ -189,6 +189,11 @@ function getCgroupMemoryLimitBytes(limitFile, logger) {
return undefined; return undefined;
} }
const displayLimit = `${Math.floor(limit / (1024 * 1024))} MiB`; const displayLimit = `${Math.floor(limit / (1024 * 1024))} MiB`;
if (limit > os.totalmem()) {
logger.debug(`While resolving RAM, ignored the file ${limitFile} that may contain a cgroup memory limit as ` +
`its contents ${displayLimit} were greater than the total amount of system memory.`);
return undefined;
}
if (limit < MINIMUM_CGROUP_MEMORY_LIMIT_BYTES) { if (limit < MINIMUM_CGROUP_MEMORY_LIMIT_BYTES) {
logger.info(`While resolving RAM, ignored a cgroup limit of ${displayLimit} in ${limitFile} as it was below ${MINIMUM_CGROUP_MEMORY_LIMIT_BYTES / (1024 * 1024)} MiB.`); logger.info(`While resolving RAM, ignored a cgroup limit of ${displayLimit} in ${limitFile} as it was below ${MINIMUM_CGROUP_MEMORY_LIMIT_BYTES / (1024 * 1024)} MiB.`);
return undefined; return undefined;

File diff suppressed because one or more lines are too long

View file

@ -260,6 +260,7 @@ function getCgroupMemoryLimitBytes(
} }
const limit = Number(fs.readFileSync(limitFile, "utf8")); const limit = Number(fs.readFileSync(limitFile, "utf8"));
if (!Number.isInteger(limit)) { if (!Number.isInteger(limit)) {
logger.debug( logger.debug(
`While resolving RAM, ignored the file ${limitFile} that may contain a cgroup memory limit ` + `While resolving RAM, ignored the file ${limitFile} that may contain a cgroup memory limit ` +
@ -269,6 +270,14 @@ function getCgroupMemoryLimitBytes(
} }
const displayLimit = `${Math.floor(limit / (1024 * 1024))} MiB`; const displayLimit = `${Math.floor(limit / (1024 * 1024))} MiB`;
if (limit > os.totalmem()) {
logger.debug(
`While resolving RAM, ignored the file ${limitFile} that may contain a cgroup memory limit as ` +
`its contents ${displayLimit} were greater than the total amount of system memory.`,
);
return undefined;
}
if (limit < MINIMUM_CGROUP_MEMORY_LIMIT_BYTES) { if (limit < MINIMUM_CGROUP_MEMORY_LIMIT_BYTES) {
logger.info( logger.info(
`While resolving RAM, ignored a cgroup limit of ${displayLimit} in ${limitFile} as it was below ${ `While resolving RAM, ignored a cgroup limit of ${displayLimit} in ${limitFile} as it was below ${