From dfabccc2ee1c4fa82fe27ce7d27782bb30892024 Mon Sep 17 00:00:00 2001 From: Travis Nielsen Date: Wed, 18 Dec 2019 14:32:47 -0700 Subject: [PATCH] ceph: rehydrate the osd CRUSH location for PVCs The OSDs on PVCs were changing location in the CRUSH hierarchy after an operator restart due to the location property not being re-discovered on the OSD daemon. Since OSDs on PVCs do not run the prepare pod again to discover this property, the operator must read it off the existing osd deployment. The operator was reading other properties, but now will read the location as well. Signed-off-by: Travis Nielsen --- pkg/operator/ceph/cluster/osd/osd.go | 7 ++++++- pkg/operator/ceph/cluster/osd/osd_test.go | 5 +++-- 2 files changed, 9 insertions(+), 3 deletions(-) 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) - }