fix: fallback to use non mount helper in case of failed mount

This commit is contained in:
Nicolas Meienberger 2026-01-08 21:44:03 +01:00
parent a44fea0737
commit 8a05423153
4 changed files with 16 additions and 14 deletions

View file

@ -34,9 +34,7 @@ const mount = async (config: BackendConfig, path: string) => {
}
if (status === "error") {
logger.debug(
`Trying to unmount any existing mounts at ${path} before mounting...`,
);
logger.debug(`Trying to unmount any existing mounts at ${path} before mounting...`);
await unmount(path);
}
@ -58,6 +56,9 @@ const mount = async (config: BackendConfig, path: string) => {
await executeMount(args);
// Fallback with -i flag if the first mount fails using the mount helper
await executeMount(["-i", ...args]);
logger.info(`NFS volume at ${path} mounted successfully.`);
return { status: BACKEND_STATUS.mounted };
};
@ -120,9 +121,7 @@ const checkHealth = async (path: string) => {
}
if (!mount.fstype.startsWith("nfs")) {
throw new Error(
`Path ${path} is not mounted as NFS (found ${mount.fstype}).`,
);
throw new Error(`Path ${path} is not mounted as NFS (found ${mount.fstype}).`);
}
logger.debug(`NFS volume at ${path} is healthy and mounted.`);
@ -140,10 +139,7 @@ const checkHealth = async (path: string) => {
}
};
export const makeNfsBackend = (
config: BackendConfig,
path: string,
): VolumeBackend => ({
export const makeNfsBackend = (config: BackendConfig, path: string): VolumeBackend => ({
mount: () => mount(config, path),
unmount: () => unmount(path),
checkHealth: () => checkHealth(path),

View file

@ -64,6 +64,9 @@ const mount = async (config: BackendConfig, path: string) => {
await executeMount(args);
// Fallback with -i flag if the first mount fails using the mount helper
await executeMount(["-i", ...args]);
logger.info(`SMB volume at ${path} mounted successfully.`);
return { status: BACKEND_STATUS.mounted };
};

View file

@ -16,13 +16,13 @@ export const executeMount = async (args: string[]): Promise<void> => {
const stderr = result.stderr.toString().trim();
if (result.exitCode === 0) {
logger.debug(stdout);
logger.debug(stderr);
if (stdout) logger.debug(stdout);
if (stderr) logger.debug(stderr);
return;
}
logger.warn(stdout);
logger.warn(stderr);
if (stdout) logger.warn(stdout);
if (stderr) logger.warn(stderr);
throw new Error(`Mount command failed with exit code ${result.exitCode}: ${stderr || stdout || "unknown error"}`);
};

View file

@ -60,6 +60,9 @@ const mount = async (config: BackendConfig, path: string) => {
const args = ["-t", "davfs", "-o", options.join(","), source, path];
await executeMount(args);
// Fallback with -i flag if the first mount fails using the mount helper
await executeMount(["-i", ...args]);
logger.info(`WebDAV volume at ${path} mounted successfully.`);
return { status: BACKEND_STATUS.mounted };
};