refactor into docker.update

This commit is contained in:
Girish Ramakrishnan
2021-01-20 12:01:15 -08:00
parent 0d535d2d5c
commit a14dbbe77a
2 changed files with 18 additions and 9 deletions
+2 -8
View File
@@ -819,12 +819,7 @@ function updateServiceConfig(platformConfig, callback) {
memorySwap = memory * 2;
}
const args = `update --memory ${memory} --memory-swap ${memorySwap} ${serviceName}`.split(' ');
// scale back db containers, if possible. this is retried because updating memory constraints can fail
// with failed to write to memory.memsw.limit_in_bytes: write /sys/fs/cgroup/memory/docker/xx/memory.memsw.limit_in_bytes: device or resource busy
async.retry({ times: 10, interval: 60 * 1000 }, function (retryCallback) {
shell.spawn(`updateServiceConfig(${serviceName})`, '/usr/bin/docker', args, { }, retryCallback);
}, iteratorCallback);
docker.update(serviceName, memory, memorySwap, iteratorCallback);
}, callback);
}
@@ -846,8 +841,7 @@ function updateAppServiceConfig(name, instance, servicesConfig, callback) {
memorySwap = memory * 2;
}
const args = `update --memory ${memory} --memory-swap ${memorySwap} ${name}-${instance}`.split(' ');
shell.spawn(`updateAppServiceConfig${name}`, '/usr/bin/docker', args, { }, callback);
docker.update(`${name}-${instance}`, memory, memorySwap, callback);
}
function startServices(existingInfra, callback) {
+16 -1
View File
@@ -29,7 +29,8 @@ exports = module.exports = {
memoryUsage,
createVolume,
removeVolume,
clearVolume
clearVolume,
update
};
var addons = require('./addons.js'),
@@ -699,3 +700,17 @@ function info(callback) {
callback(null, result);
});
}
function update(name, memory, memorySwap, callback) {
assert.strictEqual(typeof name, 'string');
assert.strictEqual(typeof memory, 'number');
assert.strictEqual(typeof memorySwap, 'number');
assert.strictEqual(typeof callback, 'function');
const args = `update --memory ${memory} --memory-swap ${memorySwap} ${name}`.split(' ');
// scale back db containers, if possible. this is retried because updating memory constraints can fail
// with failed to write to memory.memsw.limit_in_bytes: write /sys/fs/cgroup/memory/docker/xx/memory.memsw.limit_in_bytes: device or resource busy
async.retry({ times: 10, interval: 60 * 1000 }, function (retryCallback) {
shell.spawn(`update(${name})`, '/usr/bin/docker', args, { }, retryCallback);
}, callback);
}