diff --git a/src/apps.js b/src/apps.js index 139901e29..19a502f68 100644 --- a/src/apps.js +++ b/src/apps.js @@ -476,9 +476,6 @@ function install(data, auditSource, callback) { error = validateXFrameOptions(xFrameOptions); if (error) return callback(error); - // memoryLimit might come in as 0 if not specified - memoryLimit = memoryLimit || manifest.memoryLimit || constants.DEFAULT_MEMORY_LIMIT; - if (altDomain !== null && !validator.isFQDN(altDomain)) return callback(new AppsError(AppsError.BAD_FIELD, 'Invalid alt domain')); // singleUser mode requires accessRestriction to contain exactly one user @@ -572,9 +569,6 @@ function configure(appId, data, auditSource, callback) { values.memoryLimit = data.memoryLimit; error = validateMemoryLimit(app.manifest, values.memoryLimit); if (error) return callback(error); - - // memoryLimit might come in as 0 if not specified - values.memoryLimit = values.memoryLimit || app.memoryLimit || app.manifest.memoryLimit || constants.DEFAULT_MEMORY_LIMIT; } if ('xFrameOptions' in data) { diff --git a/src/docker.js b/src/docker.js index 549dd27e7..5279870cf 100644 --- a/src/docker.js +++ b/src/docker.js @@ -163,13 +163,14 @@ function createSubcontainer(app, name, cmd, options, callback) { } // first check db record, then manifest - var memoryLimit = app.memoryLimit || manifest.memoryLimit; + var memoryLimit = app.memoryLimit || manifest.memoryLimit || 0; - // ensure we never go below minimum - memoryLimit = memoryLimit < constants.DEFAULT_MEMORY_LIMIT ? constants.DEFAULT_MEMORY_LIMIT : memoryLimit; // 256mb by default - - // developerMode does not restrict memory usage - memoryLimit = developmentMode ? 0 : memoryLimit; + if (developmentMode) { + // developerMode does not restrict memory usage + memoryLimit = 0; + } else if (memoryLimit === 0 || memoryLimit < constants.DEFAULT_MEMORY_LIMIT) { // ensure we never go below minimum (in case we change the default) + memoryLimit = constants.DEFAULT_MEMORY_LIMIT; + } addons.getEnvironment(app, function (error, addonEnv) { if (error) return callback(new Error('Error getting addon environment : ' + error));