From a9e5ff07d6ca7bbfab3fd5ea2cc3c6c68b408a49 Mon Sep 17 00:00:00 2001 From: Travis Glenn Hansen Date: Tue, 20 Jun 2023 07:36:54 -0600 Subject: [PATCH] handle file missing for nvme multipath Signed-off-by: Travis Glenn Hansen --- src/utils/nvmeof.js | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/src/utils/nvmeof.js b/src/utils/nvmeof.js index 63ab2a5..e4e19aa 100644 --- a/src/utils/nvmeof.js +++ b/src/utils/nvmeof.js @@ -29,6 +29,9 @@ class NVMEoF { nvmeof.logger = nvmeof.options.logger; } else { nvmeof.logger = console; + console.verbose = function() { + console.log(...arguments); + } } } @@ -273,11 +276,33 @@ class NVMEoF { }; } + async pathExists(path) { + const nvmeof = this; + try { + await nvmeof.exec("stat", [ + path, + ]); + return true; + } catch (err) { + return false; + } + } + async nativeMultipathEnabled() { const nvmeof = this; - let result = await nvmeof.exec("cat", [ - "/sys/module/nvme_core/parameters/multipath", - ]); + let result; + + try { + result = await nvmeof.exec("cat", [ + "/sys/module/nvme_core/parameters/multipath", + ]); + } catch (err) { + if (err.code == 1 && err.stderr.includes("No such file or directory")) { + return false; + } + throw err; + } + return result.stdout.trim() == "Y"; }