forked from rook/rook
osd: prevent to fallback to lvm mode in osd on lvm creation
Rook creates raw mode OSD as possible and falls back to lvm mode if necessary. This logic doesn't work if only supports raw mode. Closes: https://github.com/rook/rook/issues/11438 Signed-off-by: Satoru Takeuchi <satoru.takeuchi@gmail.com>
This commit is contained in:
@@ -33,6 +33,7 @@ import (
|
||||
"github.com/rook/rook/pkg/clusterd"
|
||||
"github.com/rook/rook/pkg/daemon/ceph/client"
|
||||
oposd "github.com/rook/rook/pkg/operator/ceph/cluster/osd"
|
||||
"github.com/rook/rook/pkg/operator/ceph/cluster/osd/config"
|
||||
cephver "github.com/rook/rook/pkg/operator/ceph/version"
|
||||
"github.com/rook/rook/pkg/util/display"
|
||||
"github.com/rook/rook/pkg/util/sys"
|
||||
@@ -459,6 +460,19 @@ func isSafeToUseRawMode(device *DeviceOsdIDEntry, cephVersion cephver.CephVersio
|
||||
return true
|
||||
}
|
||||
|
||||
func lvmModeAllowed(device *DeviceOsdIDEntry, storeConfig *config.StoreConfig) bool {
|
||||
if device.DeviceInfo.Type == sys.LVMType {
|
||||
logger.Infof("skipping device %q for lvm mode since LVM logical volumes don't support `metadataDevice` or `osdsPerDevice` > 1", device.Config.Name)
|
||||
return false
|
||||
}
|
||||
if device.DeviceInfo.Type == sys.PartType && storeConfig.EncryptedDevice {
|
||||
logger.Infof("skipping partition %q for lvm mode since encryption is not supported on partitions with a `metadataDevice` or `osdsPerDevice > 1`", device.Config.Name)
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func (a *OsdAgent) initializeDevices(context *clusterd.Context, devices *DeviceOsdMapping) error {
|
||||
// Should we allow ceph-volume raw mode?
|
||||
allowRawMode, err := a.allowRawMode(context)
|
||||
@@ -497,7 +511,9 @@ func (a *OsdAgent) initializeDevices(context *clusterd.Context, devices *DeviceO
|
||||
rawDevices.Entries[name] = device
|
||||
continue
|
||||
}
|
||||
lvmDevices.Entries[name] = device
|
||||
if lvmModeAllowed(device, &a.storeConfig) {
|
||||
lvmDevices.Entries[name] = device
|
||||
}
|
||||
}
|
||||
|
||||
err = a.initializeDevicesRawMode(context, rawDevices)
|
||||
|
||||
@@ -1740,3 +1740,31 @@ func TestIsSafeToUseRawMode(t *testing.T) {
|
||||
assert.False(t, isSafeToUseRawMode(device, cephNextMajor))
|
||||
})
|
||||
}
|
||||
|
||||
func TestLVMModeAllowed(t *testing.T) {
|
||||
device := &DeviceOsdIDEntry{
|
||||
Config: DesiredDevice{
|
||||
Name: "vda",
|
||||
},
|
||||
DeviceInfo: &sys.LocalDisk{
|
||||
Type: sys.DiskType,
|
||||
},
|
||||
}
|
||||
storeConfig := &config.StoreConfig{EncryptedDevice: false}
|
||||
|
||||
// disk
|
||||
assert.True(t, lvmModeAllowed(device, storeConfig))
|
||||
|
||||
// lvm
|
||||
device.DeviceInfo.Type = sys.LVMType
|
||||
assert.False(t, lvmModeAllowed(device, storeConfig))
|
||||
|
||||
// non-encrypted part
|
||||
device.DeviceInfo.Type = sys.PartType
|
||||
assert.True(t, lvmModeAllowed(device, storeConfig))
|
||||
|
||||
// encrypted part
|
||||
storeConfig.EncryptedDevice = true
|
||||
assert.False(t, lvmModeAllowed(device, storeConfig))
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user