From 567ce8545e2f2231767fefc547cbce6727ef165d Mon Sep 17 00:00:00 2001 From: Travis Glenn Hansen Date: Tue, 2 Nov 2021 15:20:44 -0600 Subject: [PATCH] sanity check on publish, allow overriding the mount/unmount/findmnt command timeout Signed-off-by: Travis Glenn Hansen --- src/driver/index.js | 9 +++++++++ src/utils/mount.js | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/driver/index.js b/src/driver/index.js index 51b9968..2d51e16 100644 --- a/src/driver/index.js +++ b/src/driver/index.js @@ -1054,6 +1054,15 @@ class CsiBaseDriver { normalized_staging_path = staging_target_path; } + // sanity check to ensure the staged path is actually mounted + result = await mount.pathIsMounted(normalized_staging_path); + if (!result) { + throw new GrpcError( + grpc.status.FAILED_PRECONDITION, + `staging path is not mounted: ${normalized_staging_path}` + ); + } + result = await mount.pathIsMounted(target_path); // if not mounted, mount if (!result) { diff --git a/src/utils/mount.js b/src/utils/mount.js index 187c1d4..25bbd7b 100644 --- a/src/utils/mount.js +++ b/src/utils/mount.js @@ -10,7 +10,7 @@ FINDMNT_COMMON_OPTIONS = [ "--nofsroot", // prevents unwanted behavior with cifs volumes ]; -DEFAUT_TIMEOUT = 30000; +DEFAUT_TIMEOUT = process.env.MOUNT_DEFAULT_TIMEOUT || 30000; class Mount { constructor(options = {}) {