osd: support OSD on logical volume in host-based cluster
Rook supports raw mode OSD in host-based cluster. So we can also
support OSD on logical volume in this kind of cluster.
Logical volumes aren't picked by filters (i.e. `useAllDevices: true`
and `device{Path,}Filter` to avoid unwanted LV consumption on upgrade.
Closes: https://github.com/rook/rook/issues/2047
Signed-off-by: Satoru Takeuchi <satoru.takeuchi@gmail.com>
(cherry picked from commit 7e571f6114)
This commit is contained in:
1 parent
34c8a8f414
commit
06c7d3d682
6 files changed
+98
-17
No files matched your search
@@ -420,7 +420,58 @@ jobs:
|
||||
tests/scripts/create-bluestore-partitions.sh --disk "$BLOCK" --wipe-only
|
||||
|
||||
- name: deploy cluster
|
||||
run: tests/scripts/github-action-helper.sh deploy_cluster encryptiton
|
||||
run: tests/scripts/github-action-helper.sh deploy_cluster encryption
|
||||
|
||||
- name: wait for prepare pod
|
||||
run: tests/scripts/github-action-helper.sh wait_for_prepare_pod
|
||||
|
||||
- name: wait for ceph to be ready
|
||||
run: tests/scripts/github-action-helper.sh wait_for_ceph_to_be_ready osd 1
|
||||
|
||||
- name: check-ownerreferences
|
||||
run: tests/scripts/github-action-helper.sh check_ownerreferences
|
||||
|
||||
- name: collect common logs
|
||||
if: always()
|
||||
uses: ./.github/workflows/collect-logs
|
||||
with:
|
||||
name: canary
|
||||
|
||||
- name: setup tmate session for debugging when event is PR
|
||||
if: failure() && github.event_name == 'pull_request'
|
||||
uses: mxschmitt/action-tmate@v3
|
||||
timeout-minutes: 60
|
||||
|
||||
lvm:
|
||||
runs-on: ubuntu-18.04
|
||||
if: "!contains(github.event.pull_request.labels.*.name, 'skip-ci')"
|
||||
steps:
|
||||
- name: checkout
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: setup cluster resources
|
||||
uses: ./.github/workflows/canary-test-config
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: validate-yaml
|
||||
run: tests/scripts/github-action-helper.sh validate_yaml
|
||||
|
||||
- name: use local disk as OSD
|
||||
run: |
|
||||
BLOCK=$(sudo lsblk --paths|awk '/14G/ {print $1}'| head -1)
|
||||
tests/scripts/github-action-helper.sh use_local_disk
|
||||
tests/scripts/create-bluestore-partitions.sh --disk "$BLOCK" --wipe-only
|
||||
|
||||
- name: create LV on disk
|
||||
run: |
|
||||
BLOCK=$(sudo lsblk --paths|awk '/14G/ {print $1}'| head -1)
|
||||
tests/scripts/github-action-helper.sh create_LV_on_disk $BLOCK
|
||||
|
||||
- name: deploy cluster
|
||||
run: tests/scripts/github-action-helper.sh deploy_cluster lvm
|
||||
|
||||
- name: wait for prepare pod
|
||||
run: tests/scripts/github-action-helper.sh wait_for_prepare_pod
|
||||
|
||||
@@ -323,21 +323,21 @@ This feature is only available when `useAllNodes` has been set to `false`.
|
||||
|
||||
Below are the settings for host-based cluster. This type of cluster can specify devices for OSDs, both at the cluster and individual node level, for selecting which storage resources will be included in the cluster.
|
||||
|
||||
* `useAllDevices`: `true` or `false`, indicating whether all devices found on nodes in the cluster should be automatically consumed by OSDs. **Not recommended** unless you have a very controlled environment where you will not risk formatting of devices with existing data. When `true`, all devices/partitions will be used. Is overridden by `deviceFilter` if specified.
|
||||
* `deviceFilter`: A regular expression for short kernel names of devices (e.g. `sda`) that allows selection of devices to be consumed by OSDs. If individual devices have been specified for a node then this filter will be ignored. This field uses [golang regular expression syntax](https://golang.org/pkg/regexp/syntax/). For example:
|
||||
* `useAllDevices`: `true` or `false`, indicating whether all devices found on nodes in the cluster should be automatically consumed by OSDs. **Not recommended** unless you have a very controlled environment where you will not risk formatting of devices with existing data. When `true`, all devices and partitions will be used. Is overridden by `deviceFilter` if specified.
|
||||
* `deviceFilter`: A regular expression for short kernel names of devices (e.g. `sda`) that allows selection of devices and partitions to be consumed by OSDs. If individual devices have been specified for a node then this filter will be ignored. This field uses [golang regular expression syntax](https://golang.org/pkg/regexp/syntax/). For example:
|
||||
* `sdb`: Only selects the `sdb` device if found
|
||||
* `^sd.`: Selects all devices starting with `sd`
|
||||
* `^sd[a-d]`: Selects devices starting with `sda`, `sdb`, `sdc`, and `sdd` if found
|
||||
* `^s`: Selects all devices that start with `s`
|
||||
* `^[^r]`: Selects all devices that do *not* start with `r`
|
||||
* `devicePathFilter`: A regular expression for device paths (e.g. `/dev/disk/by-path/pci-0:1:2:3-scsi-1`) that allows selection of devices to be consumed by OSDs. If individual devices or `deviceFilter` have been specified for a node then this filter will be ignored. This field uses [golang regular expression syntax](https://golang.org/pkg/regexp/syntax/). For example:
|
||||
* `devicePathFilter`: A regular expression for device paths (e.g. `/dev/disk/by-path/pci-0:1:2:3-scsi-1`) that allows selection of devices and partitions to be consumed by OSDs. If individual devices or `deviceFilter` have been specified for a node then this filter will be ignored. This field uses [golang regular expression syntax](https://golang.org/pkg/regexp/syntax/). For example:
|
||||
* `^/dev/sd.`: Selects all devices starting with `sd`
|
||||
* `^/dev/disk/by-path/pci-.*`: Selects all devices which are connected to PCI bus
|
||||
* `devices`: A list of individual device names belonging to this node to include in the storage cluster.
|
||||
* `name`: The name of the device (e.g., `sda`), or full udev path (e.g. `/dev/disk/by-id/ata-ST4000DM004-XXXX` - this will not change after reboots).
|
||||
* `name`: The name of the devices and partitions (e.g., `sda`). The full udev path can also be specified for devices, partitions, and logical volumes (e.g. `/dev/disk/by-id/ata-ST4000DM004-XXXX` - this will not change after reboots).
|
||||
* `config`: Device-specific config settings. See the [config settings](#osd-configuration-settings) below
|
||||
|
||||
Host-based cluster only supports raw device and partition. Be sure to see the
|
||||
Host-based cluster supports raw device, partition, and logical volume. Be sure to see the
|
||||
[quickstart doc prerequisites](../../Getting-Started/quickstart.md#prerequisites) for additional considerations.
|
||||
|
||||
Below are the settings for a PVC-based cluster.
|
||||
|
||||
@@ -288,13 +288,6 @@ func getAvailableDevices(context *clusterd.Context, agent *OsdAgent) (*DeviceOsd
|
||||
|
||||
available := &DeviceOsdMapping{Entries: map[string]*DeviceOsdIDEntry{}}
|
||||
for _, device := range context.Devices {
|
||||
// Ignore 'dm' device since they are not handled by c-v properly
|
||||
// see: https://tracker.ceph.com/issues/43209
|
||||
if strings.HasPrefix(device.Name, sys.DeviceMapperPrefix) && device.Type == sys.LVMType {
|
||||
logger.Infof("skipping 'dm' device %q", device.Name)
|
||||
continue
|
||||
}
|
||||
|
||||
// Add detection for mounted device and skip if mounted
|
||||
if device.Mountpoint != "" {
|
||||
logger.Infof("skipping device %q with mountpoint %q", device.Name, device.Mountpoint)
|
||||
@@ -378,6 +371,10 @@ func getAvailableDevices(context *clusterd.Context, agent *OsdAgent) (*DeviceOsd
|
||||
deviceInfo = &DeviceOsdIDEntry{Data: unassignedOSDID, Metadata: []int{}, DeviceInfo: device}
|
||||
} else if len(desiredDevices) == 1 && desiredDevices[0].Name == "all" {
|
||||
// user has specified all devices, use the current one for data
|
||||
if device.Type == sys.LVMType {
|
||||
logger.Infof("logical volume %q is not picked by `useAllDevices: true`", device.Name)
|
||||
continue
|
||||
}
|
||||
deviceInfo = &DeviceOsdIDEntry{Data: unassignedOSDID, DeviceInfo: device}
|
||||
} else if len(desiredDevices) > 0 {
|
||||
var matched bool
|
||||
@@ -385,6 +382,10 @@ func getAvailableDevices(context *clusterd.Context, agent *OsdAgent) (*DeviceOsd
|
||||
for _, desiredDevice := range desiredDevices {
|
||||
if desiredDevice.IsFilter {
|
||||
// the desired devices is a regular expression
|
||||
if device.Type == sys.LVMType {
|
||||
logger.Infof("logical volume %q is not picked by `deviceFilter`", device.Name)
|
||||
continue
|
||||
}
|
||||
matched, err = regexp.Match(desiredDevice.Name, []byte(device.Name))
|
||||
if err != nil {
|
||||
logger.Errorf("regex failed on device %q and filter %q. %v", device.Name, desiredDevice.Name, err)
|
||||
@@ -395,6 +396,10 @@ func getAvailableDevices(context *clusterd.Context, agent *OsdAgent) (*DeviceOsd
|
||||
logger.Infof("device %q matches device filter %q", device.Name, desiredDevice.Name)
|
||||
}
|
||||
} else if desiredDevice.IsDevicePathFilter {
|
||||
if device.Type == sys.LVMType {
|
||||
logger.Infof("logical volume %q is not picked by `devicePathFilter`", device.Name)
|
||||
continue
|
||||
}
|
||||
pathnames := append(strings.Fields(device.DevLinks), filepath.Join("/dev", device.Name))
|
||||
for _, pathname := range pathnames {
|
||||
matched, err = regexp.Match(desiredDevice.Name, []byte(pathname))
|
||||
|
||||
@@ -231,6 +231,8 @@ NAME="sdb1" SIZE="30" TYPE="part" PKNAME="sdb"`, nil
|
||||
}
|
||||
|
||||
return cvInventoryOutputAvailable, nil
|
||||
} else if args[0] == "lvm" && args[1] == "list" {
|
||||
return `{}`, nil
|
||||
}
|
||||
|
||||
} else if command == "stdbuf" {
|
||||
@@ -260,7 +262,8 @@ NAME="sdb1" SIZE="30" TYPE="part" PKNAME="sdb"`, nil
|
||||
{Name: "rda", RealPath: "/dev/rda"},
|
||||
{Name: "rdb", RealPath: "/dev/rdb"},
|
||||
{Name: "sdt1", RealPath: "/dev/sdt1", Type: sys.PartType},
|
||||
{Name: "sdv1", RealPath: "/dev/sdv1", Type: sys.PartType, Filesystem: "ext2"}, // has filesystem
|
||||
{Name: "sdv1", RealPath: "/dev/sdv1", Type: sys.PartType, Filesystem: "ext2"}, // has filesystem
|
||||
{Name: "dm-0", RealPath: "/dev/mapper/vg1-lv1", DevLinks: "/dev/mapper/vg1-lv1", Type: sys.LVMType}, // `useAllDevices` and `device{,Path}Filter` don't pick up logical volumes
|
||||
}
|
||||
|
||||
version := cephver.Octopus
|
||||
@@ -289,6 +292,7 @@ NAME="sdb1" SIZE="30" TYPE="part" PKNAME="sdb"`, nil
|
||||
assert.NotContains(t, mapping.Entries, "sdb") // sdb is in use (has a partition)
|
||||
assert.NotContains(t, mapping.Entries, "sdc") // sdc is too small
|
||||
assert.NotContains(t, mapping.Entries, "sdv1") // sdv1 has a filesystem
|
||||
assert.NotContains(t, mapping.Entries, "dm-0")
|
||||
|
||||
// Do not skip partition anymore
|
||||
agent.clusterInfo.CephVersion = cephver.Octopus
|
||||
@@ -312,6 +316,12 @@ NAME="sdb1" SIZE="30" TYPE="part" PKNAME="sdb"`, nil
|
||||
assert.Equal(t, -1, mapping.Entries["sda"].Data)
|
||||
assert.Equal(t, -1, mapping.Entries["sdd"].Data)
|
||||
|
||||
// select a logical volume by deviceFilter
|
||||
agent.devices = []DesiredDevice{{Name: "dm-0", IsFilter: true}}
|
||||
mapping, err = getAvailableDevices(context, agent)
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, 0, len(mapping.Entries))
|
||||
|
||||
// select an exact device
|
||||
agent.devices = []DesiredDevice{{Name: "sdd"}}
|
||||
mapping, err = getAvailableDevices(context, agent)
|
||||
@@ -319,6 +329,13 @@ NAME="sdb1" SIZE="30" TYPE="part" PKNAME="sdb"`, nil
|
||||
assert.Equal(t, 1, len(mapping.Entries))
|
||||
assert.Equal(t, -1, mapping.Entries["sdd"].Data)
|
||||
|
||||
// select an exact logical volume
|
||||
agent.devices = []DesiredDevice{{Name: "/dev/mapper/vg1-lv1"}}
|
||||
mapping, err = getAvailableDevices(context, agent)
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, 1, len(mapping.Entries))
|
||||
assert.Equal(t, -1, mapping.Entries["dm-0"].Data)
|
||||
|
||||
// select all devices except those that have a prefix of "s"
|
||||
agent.devices = []DesiredDevice{{Name: "^[^s]", IsFilter: true}}
|
||||
mapping, err = getAvailableDevices(context, agent)
|
||||
@@ -336,6 +353,12 @@ NAME="sdb1" SIZE="30" TYPE="part" PKNAME="sdb"`, nil
|
||||
assert.Equal(t, -1, mapping.Entries["sda"].Data)
|
||||
assert.Equal(t, -1, mapping.Entries["sdd"].Data)
|
||||
|
||||
// select a logical volume by devicePathFilter
|
||||
agent.devices = []DesiredDevice{{Name: "dm-0", IsDevicePathFilter: true}}
|
||||
mapping, err = getAvailableDevices(context, agent)
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, 0, len(mapping.Entries))
|
||||
|
||||
// select the devices that have udev persistent names by devicePathFilter
|
||||
agent.devices = []DesiredDevice{{Name: "^/dev/disk/by-path/.*-scsi-.*", IsDevicePathFilter: true}}
|
||||
mapping, err = getAvailableDevices(context, agent)
|
||||
|
||||
@@ -297,9 +297,6 @@ func CheckIfDeviceAvailable(executor exec.Executor, devicePath string, pvcBacked
|
||||
return false, "", fmt.Errorf("failed to determine if the device was LV. %v", err)
|
||||
}
|
||||
if isLV {
|
||||
if !pvcBacked {
|
||||
return false, "LV is not supported for non-PVC backed device", nil
|
||||
}
|
||||
checker = isLVAvailable
|
||||
}
|
||||
|
||||
|
||||
@@ -216,6 +216,11 @@ function deploy_cluster() {
|
||||
sed -i "s|#deviceFilter:|deviceFilter: ${BLOCK/\/dev\/}\n config:\n metadataDevice: /dev/test-rook-vg/test-rook-lv|g" cluster-test.yaml
|
||||
elif [ "$1" = "encryption" ] ; then
|
||||
sed -i "s|#deviceFilter:|deviceFilter: ${BLOCK/\/dev\/}\n config:\n encryptedDevice: \"true\"|g" cluster-test.yaml
|
||||
elif [ "$1" = "lvm" ] ; then
|
||||
sed -i "s|#deviceFilter:|devices:\n - name: \"/dev/test-rook-vg/test-rook-lv\"|g" cluster-test.yaml
|
||||
else
|
||||
echo "invalid argument: $*" >&2
|
||||
exit 1
|
||||
fi
|
||||
kubectl create -f cluster-test.yaml
|
||||
kubectl create -f object-test.yaml
|
||||
|
||||
Reference in new issue
Block a user