diff --git a/src/addons.js b/src/addons.js index 275d6dd34..d5a521432 100644 --- a/src/addons.js +++ b/src/addons.js @@ -752,8 +752,8 @@ function setupLocalStorage(app, options, callback) { // reomve any existing volume in case it's bound with an old dataDir async.series([ - docker.removeVolume.bind(null, app, `${app.id}-localstorage`), - docker.createVolume.bind(null, app, `${app.id}-localstorage`, volumeDataDir) + docker.removeVolume.bind(null, `${app.id}-localstorage`), + docker.createVolume.bind(null, `${app.id}-localstorage`, volumeDataDir, { fqdn: app.fqdn, appId: app.id }) ], callback); } @@ -764,7 +764,7 @@ function clearLocalStorage(app, options, callback) { debugApp(app, 'clearLocalStorage'); - docker.clearVolume(app, `${app.id}-localstorage`, { removeDirectory: false }, callback); + docker.clearVolume(`${app.id}-localstorage`, { removeDirectory: false }, callback); } function teardownLocalStorage(app, options, callback) { @@ -775,8 +775,8 @@ function teardownLocalStorage(app, options, callback) { debugApp(app, 'teardownLocalStorage'); async.series([ - docker.clearVolume.bind(null, app, `${app.id}-localstorage`, { removeDirectory: true }), - docker.removeVolume.bind(null, app, `${app.id}-localstorage`) + docker.clearVolume.bind(null, `${app.id}-localstorage`, { removeDirectory: true }), + docker.removeVolume.bind(null, `${app.id}-localstorage`) ], callback); } diff --git a/src/docker.js b/src/docker.js index 84206a9bb..95b07085a 100644 --- a/src/docker.js +++ b/src/docker.js @@ -573,10 +573,10 @@ function memoryUsage(containerId, callback) { }); } -function createVolume(app, name, volumeDataDir, callback) { - assert.strictEqual(typeof app, 'object'); +function createVolume(name, volumeDataDir, labels, callback) { assert.strictEqual(typeof name, 'string'); assert.strictEqual(typeof volumeDataDir, 'string'); + assert.strictEqual(typeof labels, 'object'); assert.strictEqual(typeof callback, 'function'); const volumeOptions = { @@ -587,10 +587,7 @@ function createVolume(app, name, volumeDataDir, callback) { device: volumeDataDir, o: 'bind' }, - Labels: { - 'fqdn': app.fqdn, - 'appId': app.id - }, + Labels: labels }; // requires sudo because the path can be outside appsdata @@ -605,8 +602,7 @@ function createVolume(app, name, volumeDataDir, callback) { }); } -function clearVolume(app, name, options, callback) { - assert.strictEqual(typeof app, 'object'); +function clearVolume(name, options, callback) { assert.strictEqual(typeof name, 'string'); assert.strictEqual(typeof options, 'object'); assert.strictEqual(typeof callback, 'function'); @@ -626,14 +622,13 @@ function clearVolume(app, name, options, callback) { } // this only removes the volume and not the data -function removeVolume(app, name, callback) { - assert.strictEqual(typeof app, 'object'); +function removeVolume(name, callback) { assert.strictEqual(typeof name, 'string'); assert.strictEqual(typeof callback, 'function'); let volume = gConnection.getVolume(name); volume.remove(function (error) { - if (error && error.statusCode !== 404) return callback(new BoxError(BoxError.DOCKER_ERROR, `removeVolume: Error removing volume of ${app.id} ${error.message}`)); + if (error && error.statusCode !== 404) return callback(new BoxError(BoxError.DOCKER_ERROR, `removeVolume: Error removing volume: ${error.message}`)); callback(); });