Skip to content

Commit

Permalink
Merge pull request #8267 from lyind/master
Browse files Browse the repository at this point in the history
ceph: fix lvm osd db device check
  • Loading branch information
travisn committed Sep 13, 2021
2 parents 1df2e93 + 0e72a7c commit 99811e5
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pkg/daemon/ceph/osd/volume.go
Expand Up @@ -808,7 +808,7 @@ func (a *OsdAgent) initializeDevicesLVMMode(context *clusterd.Context, devices *
}

for _, report := range cvReports {
if report.BlockDB != mdPath {
if report.BlockDB != mdPath && !strings.HasSuffix(mdPath, report.BlockDB) {
return errors.Errorf("wrong db device for %s, required: %s, actual: %s", report.Data, mdPath, report.BlockDB)
}
}
Expand Down
53 changes: 46 additions & 7 deletions pkg/daemon/ceph/osd/volume_test.go
Expand Up @@ -1333,15 +1333,14 @@ func TestIsNewStyledLvmBatch(t *testing.T) {
}

func TestInitializeBlockWithMD(t *testing.T) {
// Common vars for all the tests
devices := &DeviceOsdMapping{
Entries: map[string]*DeviceOsdIDEntry{
"sda": {Data: -1, Metadata: nil, Config: DesiredDevice{Name: "/dev/sda", MetadataDevice: "/dev/sdd"}},
},
}

// Test default behavior
{
devices := &DeviceOsdMapping{
Entries: map[string]*DeviceOsdIDEntry{
"sda": {Data: -1, Metadata: nil, Config: DesiredDevice{Name: "/dev/sda", MetadataDevice: "/dev/sdd"}},
},
}

executor := &exectest.MockExecutor{}
executor.MockExecuteCommand = func(command string, args ...string) error {
logger.Infof("%s %v", command, args)
Expand Down Expand Up @@ -1373,6 +1372,46 @@ func TestInitializeBlockWithMD(t *testing.T) {
err := a.initializeDevicesLVMMode(context, devices)
assert.NoError(t, err, "failed default behavior test")
}

// Test initialize with LV as metadata devices
{
devices := &DeviceOsdMapping{
Entries: map[string]*DeviceOsdIDEntry{
"sda": {Data: -1, Metadata: nil, Config: DesiredDevice{Name: "/dev/sda", MetadataDevice: "vg0/lv0"}},
},
}
executor := &exectest.MockExecutor{}
executor.MockExecuteCommand = func(command string, args ...string) error {
logger.Infof("%s %v", command, args)

// Validate base common args
err := testBaseArgs(args)
if err != nil {
return err
}

// Second command
if args[9] == "--osds-per-device" && args[10] == "1" && args[11] == "/dev/sda" && args[12] == "--db-devices" && args[13] == "/dev/vg0/lv0" {
return nil
}

return errors.Errorf("unknown command %s %s", command, args)
}
executor.MockExecuteCommandWithOutput = func(command string, args ...string) (string, error) {
// First command
if args[9] == "--osds-per-device" && args[10] == "1" && args[11] == "/dev/sda" && args[12] == "--db-devices" && args[13] == "/dev/vg0/lv0" && args[14] == "--report" {
return `[{"block_db": "vg0/lv0", "encryption": "None", "data": "/dev/sda", "data_size": "100.00 GB", "block_db_size": "10.00 GB"}]`, nil
}

return "", errors.Errorf("unknown command %s %s", command, args)
}
a := &OsdAgent{clusterInfo: &cephclient.ClusterInfo{CephVersion: cephver.CephVersion{Major: 16, Minor: 2, Extra: 4}}, nodeName: "node1"}
context := &clusterd.Context{Executor: executor}

err := a.initializeDevicesLVMMode(context, devices)
assert.NoError(t, err, "failed LV as metadataDevice test")
}

}

func TestUseRawMode(t *testing.T) {
Expand Down

0 comments on commit 99811e5

Please sign in to comment.