resize support for device-mapper/multipath

This commit is contained in:
Travis Glenn Hansen 2020-11-29 10:02:53 -07:00
parent da6ff1b950
commit a519c3fff4
4 changed files with 40 additions and 5 deletions

View File

@ -38,6 +38,9 @@ RUN apt-get update && \
ADD docker/iscsiadm /usr/local/sbin
RUN chmod +x /usr/local/sbin/iscsiadm
ADD docker/multipath /usr/local/sbin
RUN chmod +x /usr/local/sbin/multipath
# Run as a non-root user
RUN useradd --create-home csi \
&& mkdir /home/csi/app \

3
docker/multipath Normal file
View File

@ -0,0 +1,3 @@
#!/bin/bash
chroot /host /usr/bin/env -i PATH="/sbin:/bin:/usr/sbin:/usr/bin" multipath "${@:1}"

View File

@ -395,6 +395,10 @@ class CsiBaseDriver {
}
}
// let things settle
// this will help in dm scenarios
await sleep(2000);
// filter duplicates
iscsiDevices = iscsiDevices.filter((value, index, self) => {
return self.indexOf(value) === index;
@ -936,6 +940,7 @@ class CsiBaseDriver {
let is_block = false;
let is_formatted;
let fs_type;
let is_device_mapper = false;
const volume_id = call.request.volume_id;
const volume_path = call.request.volume_path;
@ -972,7 +977,24 @@ class CsiBaseDriver {
}
if (is_block) {
await filesystem.rescanDevice(device);
let rescan_devices = [];
// detect if is a multipath device
is_device_mapper = await filesystem.isDeviceMapperDevice(device);
if (is_device_mapper) {
// NOTE: want to make sure we scan the dm device *after* all the underlying slaves
rescan_devices = await filesystem.getDeviceMapperDeviceSlaves(device);
}
rescan_devices.push(device);
for (let sdevice of rescan_devices) {
await filesystem.rescanDevice(sdevice);
}
// let things settle
// it appears the dm devices can take a second to figure things out
await sleep(2000);
if (is_formatted && access_type == "mount") {
fs_info = await filesystem.getDeviceFilesystemInfo(device);
fs_type = fs_info.type;

View File

@ -415,12 +415,19 @@ class Filesystem {
);
}
let is_device_mapper_device = await filesystem.isDeviceMapperDevice(device);
result = await filesystem.realpath(device);
device_name = result.split("/").pop();
// echo 1 > /sys/block/sdb/device/rescan
const sys_file = `/sys/block/${device_name}/device/rescan`;
fs.writeFileSync(sys_file, "1");
if (is_device_mapper_device) {
// multipath -r /dev/dm-0
result = await filesystem.exec("multipath", ["-r", device]);
} else {
device_name = result.split("/").pop();
// echo 1 > /sys/block/sdb/device/rescan
const sys_file = `/sys/block/${device_name}/device/rescan`;
fs.writeFileSync(sys_file, "1");
}
}
/**