mount: if unmount failed, do not proceed

This commit is contained in:
Girish Ramakrishnan
2021-06-22 09:53:31 -07:00
parent 5040b4f3f9
commit 15ff43369f
2 changed files with 9 additions and 4 deletions

View File

@@ -158,7 +158,8 @@ async function tryAddMount(volume, options) {
if (!safe.fs.writeFileSync(keyFilePath, `${volume.mountOptions.privateKey}\n`, { mode: 0o600 })) throw new BoxError(BoxError.FS_ERROR, safe.error);
}
await safe(shell.promises.sudo('addMount', [ ADD_MOUNT_CMD, renderMountFile(volume), options.timeout ], {}));
const [error] = await safe(shell.promises.sudo('addMount', [ ADD_MOUNT_CMD, renderMountFile(volume), options.timeout ], {}));
if (error && error.code === 2) throw new BoxError(BoxError.MOUNT_ERROR, 'Failed to unmount existing mount'); // at this point, the old mount config is still there
const status = await getStatus(volume.mountType, volume.hostPath);
if (status.state !== 'active') { // cleanup