Remove all app containers before removing volume

If volume location changes, we re-create the volume. However, volume
can only be removed if all the containers using it are deleted. For
example, the scheduler might be running a container using it.
This commit is contained in:
Girish Ramakrishnan
2019-01-17 23:32:24 -08:00
parent ab35821b59
commit 4a9b0e8db6
4 changed files with 18 additions and 26 deletions

View File

@@ -371,15 +371,19 @@ function deleteContainer(containerId, callback) {
});
}
function deleteContainers(appId, callback) {
function deleteContainers(appId, options, callback) {
assert.strictEqual(typeof appId, 'string');
assert.strictEqual(typeof options, 'object');
assert.strictEqual(typeof callback, 'function');
var docker = exports.connection;
debug('deleting containers of %s', appId);
docker.listContainers({ all: 1, filters: JSON.stringify({ label: [ 'appId=' + appId ] }) }, function (error, containers) {
let labels = [ 'appId=' + appId ];
if (options.managedOnly) labels.push('isCloudronManaged=true');
docker.listContainers({ all: 1, filters: JSON.stringify({ label: labels }) }, function (error, containers) {
if (error) return callback(error);
async.eachSeries(containers, function (container, iteratorDone) {