diff --git a/pkg/operator/ceph/cluster/osd/osd.go b/pkg/operator/ceph/cluster/osd/osd.go index b20bd4a2c..2963e30b6 100644 --- a/pkg/operator/ceph/cluster/osd/osd.go +++ b/pkg/operator/ceph/cluster/osd/osd.go @@ -719,9 +719,14 @@ func getOSDInfo(d *apps.Deployment) ([]OSDInfo, error) { if strings.HasPrefix(a, "--setuser-match-path") { if len(container.Args) >= i+1 { osd.DataPath = container.Args[i+1] - break } } + locationPrefix := "--crush-location=" + if strings.HasPrefix(a, locationPrefix) { + // Extract the same CRUSH location as originally determined by the OSD prepare pod + // by cutting off the prefix: --crush-location= + osd.Location = a[len(locationPrefix):] + } } osd.CephVolumeInitiated = true diff --git a/pkg/operator/ceph/cluster/osd/osd_test.go b/pkg/operator/ceph/cluster/osd/osd_test.go index fcd6ee6e6..5ab26d4b0 100644 --- a/pkg/operator/ceph/cluster/osd/osd_test.go +++ b/pkg/operator/ceph/cluster/osd/osd_test.go @@ -385,7 +385,8 @@ func TestGetOSDInfo(t *testing.T) { v1.ResourceRequirements{}, v1.ResourceRequirements{}, "my-priority-class", metav1.OwnerReference{}, false, false) node := "n1" - osd1 := OSDInfo{ID: 3, UUID: "osd-uuid", LVPath: "dev/logical-volume-path", DataPath: "/rook/path", CephVolumeInitiated: true} + location := "root=default host=myhost zone=myzone" + osd1 := OSDInfo{ID: 3, UUID: "osd-uuid", LVPath: "dev/logical-volume-path", DataPath: "/rook/path", CephVolumeInitiated: true, Location: location} osd2 := OSDInfo{ID: 3, UUID: "osd-uuid", LVPath: "", DataPath: "/rook/path", CephVolumeInitiated: true} osdProp := osdProperties{ crushHostname: node, @@ -402,10 +403,10 @@ func TestGetOSDInfo(t *testing.T) { assert.Equal(t, 1, len(osds1)) assert.Equal(t, osd1.ID, osds1[0].ID) assert.Equal(t, osd1.LVPath, osds1[0].LVPath) + assert.Equal(t, location, osds1[0].Location) d2, _ := c.makeDeployment(osdProp, osd2, dataPathMap) osds2, err := getOSDInfo(d2) assert.Equal(t, 0, len(osds2)) assert.NotNil(t, err) - }