mongodb: do not apply memory limit when no avx

This commit is contained in:
Girish Ramakrishnan
2024-06-23 21:05:39 +02:00
parent c1c864ced7
commit 345f9541fe

View File

@@ -281,6 +281,12 @@ function requiresUpgrade(existingObjOrImageName, currentImageName) {
return etag.version.major !== ctag.version.major;
}
async function hasAVX() {
// mongodb 5 and above requires AVX
const [error] = await safe(shell.exec('hasAVX', 'grep -q avx /proc/cpuinfo', {}));
return !error;
}
// paths for dumps
function dumpPath(addon, appId) {
switch (addon) {
@@ -763,6 +769,11 @@ async function applyMemoryLimit(id) {
containerName = `${name}-${instance}`;
memoryLimit = serviceConfig && serviceConfig.memoryLimit ? serviceConfig.memoryLimit : APP_SERVICES[name].defaultMemoryLimit;
} else if (SERVICES[name]) {
if (name === 'mongodb' && !await hasAVX()) {
debug('applyMemoryLimit: skipping mongodb because CPU does not have AVX');
return;
}
containerName = name;
memoryLimit = serviceConfig && serviceConfig.memoryLimit ? serviceConfig.memoryLimit : SERVICES[name].defaultMemoryLimit;
} else {
@@ -1488,12 +1499,6 @@ async function restorePostgreSql(app, options) {
await pipeFileToRequest(dumpPath('postgresql', app.id), `http://${result.ip}:3000/databases/${database}/restore?access_token=${result.token}&username=${username}`);
}
async function hasAVX() {
// mongodb 5 and above requires AVX
const [error] = await safe(shell.exec('hasAVX', 'grep -q avx /proc/cpuinfo', {}));
return !error;
}
async function startMongodb(existingInfra) {
assert.strictEqual(typeof existingInfra, 'object');