Merge pull request #9849 from rook/mergify/bp/release-1.8/pr-9842
osd: disable raw mode for specific disk configs (backport #9842)
This commit is contained in:
2 files changed
+84
-11
No files matched your search
@@ -463,7 +463,7 @@ func (a *OsdAgent) allowRawMode(context *clusterd.Context) (bool, error) {
|
||||
allowRawMode = false
|
||||
}
|
||||
|
||||
// ceph-volume raw mode mode does not support metadata device if not running on PVC because the user has specified a whole device
|
||||
// ceph-volume raw mode does not support metadata device if not running on PVC because the user has specified a whole device
|
||||
if a.metadataDevice != "" {
|
||||
logger.Debugf("won't use raw mode since there is a metadata device %q", a.metadataDevice)
|
||||
allowRawMode = false
|
||||
@@ -472,14 +472,29 @@ func (a *OsdAgent) allowRawMode(context *clusterd.Context) (bool, error) {
|
||||
return allowRawMode, nil
|
||||
}
|
||||
|
||||
func isSafeToUseRawMode(deviceType string, cephVersion cephver.CephVersion) bool {
|
||||
if deviceType != sys.DiskType {
|
||||
return true
|
||||
// test if safe to use raw mode for a particular device
|
||||
func isSafeToUseRawMode(device *DeviceOsdIDEntry, cephVersion cephver.CephVersion) bool {
|
||||
if device.DeviceInfo.Type == sys.DiskType {
|
||||
// if this is a disk but the atari partition fix isn't in, we can't use raw mode
|
||||
if !cephVersion.IsAtLeast(cephIgnorePhantomAtariPartitionCephVersion) {
|
||||
logger.Debugf("won't use raw mode for disk %q since this is a disk and the atari partition issue isn't fixed", device.Config.Name)
|
||||
return false
|
||||
}
|
||||
}
|
||||
if cephVersion.IsAtLeast(cephIgnorePhantomAtariPartitionCephVersion) {
|
||||
return true
|
||||
|
||||
// ceph-volume raw mode does not support more than one OSD per disk
|
||||
if device.Config.OSDsPerDevice > 1 {
|
||||
logger.Debugf("won't use raw mode for disk %q since osd per device is %d", device.Config.Name, device.Config.OSDsPerDevice)
|
||||
return false
|
||||
}
|
||||
return false
|
||||
|
||||
// ceph-volume raw mode does not support metadata device if not running on PVC because the user has specified a whole device
|
||||
if device.Config.MetadataDevice != "" {
|
||||
logger.Debugf("won't use raw mode for disk %q since this disk has a metadata device", device.Config.Name)
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func (a *OsdAgent) initializeDevices(context *clusterd.Context, devices *DeviceOsdMapping) error {
|
||||
@@ -516,7 +531,7 @@ func (a *OsdAgent) initializeDevices(context *clusterd.Context, devices *DeviceO
|
||||
// which reports only the phantom partitions (and malformed OSD info) when they exist and
|
||||
// ignores the original (correct) OSDs created on the raw disk.
|
||||
// See: https://github.com/rook/rook/issues/7940
|
||||
if allowRawMode && isSafeToUseRawMode(device.DeviceInfo.Type, a.clusterInfo.CephVersion) {
|
||||
if allowRawMode && isSafeToUseRawMode(device, a.clusterInfo.CephVersion) {
|
||||
rawDevices.Entries[name] = device
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -1380,7 +1380,65 @@ func TestAppendOSDInfo(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestIsSafeToUseRawMode(t *testing.T) {
|
||||
assert.Equal(t, true, isSafeToUseRawMode(sys.PartType, cephver.CephVersion{Major: 16, Minor: 2, Extra: 5}))
|
||||
assert.Equal(t, false, isSafeToUseRawMode(sys.DiskType, cephver.CephVersion{Major: 16, Minor: 2, Extra: 5}))
|
||||
assert.Equal(t, true, isSafeToUseRawMode(sys.DiskType, cephver.CephVersion{Major: 16, Minor: 2, Extra: 6}))
|
||||
baseDisk := func() *DeviceOsdIDEntry {
|
||||
return &DeviceOsdIDEntry{
|
||||
Config: DesiredDevice{
|
||||
Name: "vda",
|
||||
},
|
||||
DeviceInfo: &sys.LocalDisk{
|
||||
Name: "vda",
|
||||
Type: sys.DiskType,
|
||||
},
|
||||
}
|
||||
}
|
||||
basePart := func() *DeviceOsdIDEntry {
|
||||
return &DeviceOsdIDEntry{
|
||||
Config: DesiredDevice{
|
||||
Name: "vda1",
|
||||
},
|
||||
DeviceInfo: &sys.LocalDisk{
|
||||
Name: "vda1",
|
||||
Type: sys.PartType,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
cephPrevMajor := cephver.CephVersion{Major: 15, Minor: 2, Extra: 15}
|
||||
cephBeforeAtariPatch := cephver.CephVersion{Major: 16, Minor: 2, Extra: 5}
|
||||
cephWithAtariPatch := cephver.CephVersion{Major: 16, Minor: 2, Extra: 6}
|
||||
cephNextMajor := cephver.CephVersion{Major: 17, Minor: 2, Extra: 0}
|
||||
|
||||
t.Run("safe for partitions with all Ceph versions", func(t *testing.T) {
|
||||
device := basePart()
|
||||
assert.True(t, isSafeToUseRawMode(device, cephPrevMajor))
|
||||
assert.True(t, isSafeToUseRawMode(device, cephBeforeAtariPatch))
|
||||
assert.True(t, isSafeToUseRawMode(device, cephWithAtariPatch))
|
||||
assert.True(t, isSafeToUseRawMode(device, cephNextMajor))
|
||||
})
|
||||
|
||||
t.Run("safe for disks only with atari patch", func(t *testing.T) {
|
||||
device := baseDisk()
|
||||
// make sure it's still unsafe for previous ceph version
|
||||
assert.False(t, isSafeToUseRawMode(device, cephPrevMajor))
|
||||
assert.False(t, isSafeToUseRawMode(device, cephBeforeAtariPatch))
|
||||
assert.True(t, isSafeToUseRawMode(device, cephWithAtariPatch))
|
||||
// make sure it's still safe when next ceph version comes out
|
||||
assert.True(t, isSafeToUseRawMode(device, cephNextMajor))
|
||||
})
|
||||
|
||||
t.Run("not safe if OSDs per device > 1", func(t *testing.T) {
|
||||
device := baseDisk()
|
||||
device.Config.OSDsPerDevice = 2
|
||||
// we only care about the cases where disks would otherwise be safe
|
||||
assert.False(t, isSafeToUseRawMode(device, cephWithAtariPatch))
|
||||
assert.False(t, isSafeToUseRawMode(device, cephNextMajor))
|
||||
})
|
||||
|
||||
t.Run("not safe if metadata device specified", func(t *testing.T) {
|
||||
device := baseDisk()
|
||||
device.Config.MetadataDevice = "vdb1"
|
||||
// we only care about the cases where disks would otherwise be safe
|
||||
assert.False(t, isSafeToUseRawMode(device, cephWithAtariPatch))
|
||||
assert.False(t, isSafeToUseRawMode(device, cephNextMajor))
|
||||
})
|
||||
}
|
||||
Reference in new issue
Block a user