sftp: rework appdata and volume mounting logic

this tries to solve two issues:

* the current approach mounts the data directories of apps/volumes individually.
this causes a problem with volume mounts that mount after the container is started i.e not
network time/delay but systemd ordering. With CIFS, the mount is a hostname. This requires
unbound to be running but unbound can only start after docker because it wants to bind to
the docker network. one way to fix is to not start sftp automatically and only start sftp
container in the box code. This results in the sftp container attaching itself of the
directory before mounting and it appears empty. (on the host, the directory will appear
to have mount data!)

* every time apptask runs we keep rebuilding this sftp container. this results in much race.

the fix is: mount the parent directory of apps and volumes. in addition, then any specialized appdata
paths and volume paths are mounted individually. this greatly minimized rebuilding and also since we don't rely
on binding to the mount point itself. the child directories can mount in leisure. this limits the race
issue to only no-op volume mounts.

part of #789
This commit is contained in:
Girish Ramakrishnan
2021-06-24 16:19:30 -07:00
parent 87b2b63043
commit 097a7d6b60
6 changed files with 60 additions and 67 deletions

View File

@@ -137,6 +137,7 @@ const appdb = require('./appdb.js'),
reverseProxy = require('./reverseproxy.js'),
safe = require('safetydance'),
semver = require('semver'),
services = require('./services.js'),
settings = require('./settings.js'),
spawn = require('child_process').spawn,
split = require('split'),
@@ -1273,7 +1274,10 @@ function setDataDir(app, dataDir, auditSource, callback) {
const task = {
args: { newDataDir: dataDir },
values: { }
values: { },
onFinished: (error) => {
if (!error) services.rebuildService('sftp', NOOP_CALLBACK);
}
};
addTask(appId, exports.ISTATE_PENDING_DATA_DIR_MIGRATION, task, function (error, result) {
if (error) return callback(error);