diff --git a/src/driver/index.js b/src/driver/index.js index 9e62d68..cff19b6 100644 --- a/src/driver/index.js +++ b/src/driver/index.js @@ -571,7 +571,33 @@ class CsiBaseDriver { case "ext3": case "ext4dev": //await filesystem.checkFilesystem(device, fs_info.type); - await filesystem.expandFilesystem(device, fs_type); + try { + await filesystem.expandFilesystem(device, fs_type); + } catch (err) { + // mount is clean and rw, but it will not expand until clean umount has been done + // failed to execute filesystem command: resize2fs /dev/sda, response: {"code":1,"stdout":"Couldn't find valid filesystem superblock.\n","stderr":"resize2fs 1.44.5 (15-Dec-2018)\nresize2fs: Superblock checksum does not match superblock while trying to open /dev/sda\n"} + // /dev/sda on /var/lib/kubelet/plugins/kubernetes.io/csi/pv/pvc-4a80757e-5e87-475d-826f-44fcc4719348/globalmount type ext4 (rw,relatime,stripe=256) + if ( + err.code == 1 && + err.stdout.includes("find valid filesystem superblock") && + err.stderr.includes("checksum does not match superblock") + ) { + driver.ctx.logger.warn( + `successful mount, unsuccessful fs resize: attempting abnormal umount/mount/resize2fs to clear things up ${staging_target_path} (${device})` + ); + + // try an unmount/mount/fsck cycle again just to clean things up + await mount.umount(staging_target_path, []); + await mount.mount( + device, + staging_target_path, + ["-t", fs_type].concat(["-o", mount_flags.join(",")]) + ); + await filesystem.expandFilesystem(device, fs_type); + } else { + throw err; + } + } break; case "xfs": //await filesystem.checkFilesystem(device, fs_info.type); diff --git a/src/utils/filesystem.js b/src/utils/filesystem.js index 53d8d99..4937863 100644 --- a/src/utils/filesystem.js +++ b/src/utils/filesystem.js @@ -426,12 +426,13 @@ class Filesystem { // echo 1 > /sys/block/sdb/device/rescan const sys_file = `/sys/block/${device_name}/device/rescan`; + console.log(`executing filesystem command: echo 1 > ${sys_file}`); fs.writeFileSync(sys_file, "1"); } } /** - * expand a give filesystem + * expand a given filesystem * * @param {*} device * @param {*} fstype @@ -474,7 +475,7 @@ class Filesystem { } /** - * expand a give filesystem + * check a given filesystem * * fsck [options] -- [fs-options] [ ...] * @@ -593,7 +594,7 @@ class Filesystem { args.unshift(command); command = filesystem.options.paths.sudo; } - console.log("executing fileystem command: %s %s", command, args.join(" ")); + console.log("executing filesystem command: %s %s", command, args.join(" ")); const child = filesystem.options.executor.spawn(command, args, options); let didTimeout = false;