resize support for device-mapper/multipath
This commit is contained in:
parent
da6ff1b950
commit
a519c3fff4
|
|
@ -38,6 +38,9 @@ RUN apt-get update && \
|
||||||
ADD docker/iscsiadm /usr/local/sbin
|
ADD docker/iscsiadm /usr/local/sbin
|
||||||
RUN chmod +x /usr/local/sbin/iscsiadm
|
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 as a non-root user
|
||||||
RUN useradd --create-home csi \
|
RUN useradd --create-home csi \
|
||||||
&& mkdir /home/csi/app \
|
&& mkdir /home/csi/app \
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
chroot /host /usr/bin/env -i PATH="/sbin:/bin:/usr/sbin:/usr/bin" multipath "${@:1}"
|
||||||
|
|
@ -395,6 +395,10 @@ class CsiBaseDriver {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// let things settle
|
||||||
|
// this will help in dm scenarios
|
||||||
|
await sleep(2000);
|
||||||
|
|
||||||
// filter duplicates
|
// filter duplicates
|
||||||
iscsiDevices = iscsiDevices.filter((value, index, self) => {
|
iscsiDevices = iscsiDevices.filter((value, index, self) => {
|
||||||
return self.indexOf(value) === index;
|
return self.indexOf(value) === index;
|
||||||
|
|
@ -936,6 +940,7 @@ class CsiBaseDriver {
|
||||||
let is_block = false;
|
let is_block = false;
|
||||||
let is_formatted;
|
let is_formatted;
|
||||||
let fs_type;
|
let fs_type;
|
||||||
|
let is_device_mapper = false;
|
||||||
|
|
||||||
const volume_id = call.request.volume_id;
|
const volume_id = call.request.volume_id;
|
||||||
const volume_path = call.request.volume_path;
|
const volume_path = call.request.volume_path;
|
||||||
|
|
@ -972,7 +977,24 @@ class CsiBaseDriver {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_block) {
|
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") {
|
if (is_formatted && access_type == "mount") {
|
||||||
fs_info = await filesystem.getDeviceFilesystemInfo(device);
|
fs_info = await filesystem.getDeviceFilesystemInfo(device);
|
||||||
fs_type = fs_info.type;
|
fs_type = fs_info.type;
|
||||||
|
|
|
||||||
|
|
@ -415,13 +415,20 @@ class Filesystem {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let is_device_mapper_device = await filesystem.isDeviceMapperDevice(device);
|
||||||
result = await filesystem.realpath(device);
|
result = await filesystem.realpath(device);
|
||||||
|
|
||||||
|
if (is_device_mapper_device) {
|
||||||
|
// multipath -r /dev/dm-0
|
||||||
|
result = await filesystem.exec("multipath", ["-r", device]);
|
||||||
|
} else {
|
||||||
device_name = result.split("/").pop();
|
device_name = result.split("/").pop();
|
||||||
|
|
||||||
// echo 1 > /sys/block/sdb/device/rescan
|
// echo 1 > /sys/block/sdb/device/rescan
|
||||||
const sys_file = `/sys/block/${device_name}/device/rescan`;
|
const sys_file = `/sys/block/${device_name}/device/rescan`;
|
||||||
fs.writeFileSync(sys_file, "1");
|
fs.writeFileSync(sys_file, "1");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* expand a give filesystem
|
* expand a give filesystem
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue