From 4224f84d7c866359d693bfb12a4eccf458739796 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Han?= Date: Mon, 23 Dec 2019 15:36:49 +0100 Subject: [PATCH] ceph: osd add missing ROOK_CEPH_MON_HOST env MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The ROOK_CEPH_MON_HOST env var was missing from the pod env so the CEPH_ARGS won't be populated correctly. Closes: https://github.com/rook/rook/issues/4558 Signed-off-by: Sébastien Han --- pkg/operator/ceph/cluster/osd/spec.go | 17 ++++++++++++++--- pkg/operator/ceph/cluster/osd/spec_test.go | 14 ++++++++++++++ 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/pkg/operator/ceph/cluster/osd/spec.go b/pkg/operator/ceph/cluster/osd/spec.go index d56b59e5a..82c7374e4 100644 --- a/pkg/operator/ceph/cluster/osd/spec.go +++ b/pkg/operator/ceph/cluster/osd/spec.go @@ -564,9 +564,7 @@ func (c *Cluster) getCopyBinariesContainer() (v1.Volume, *v1.Container) { // This container runs all the actions needed to activate an OSD before we can run the OSD process func (c *Cluster) getActivateOSDInitContainer(osdID, osdUUID string, isFilestore bool, osdProps osdProperties) (v1.Volume, *v1.Container) { volume := v1.Volume{Name: activateOSDVolumeName, VolumeSource: v1.VolumeSource{EmptyDir: &v1.EmptyDirVolumeSource{}}} - envVars := cephVolumeEnvVar() - envVars = append(envVars, v1.EnvVar{Name: "CEPH_ARGS", Value: "-m $(ROOK_CEPH_MON_HOST)"}) - + envVars := osdActivateEnvVar() osdStore := "--bluestore" if isFilestore { osdStore = "--filestore" @@ -1055,6 +1053,19 @@ func cephVolumeEnvVar() []v1.EnvVar { } } +func osdActivateEnvVar() []v1.EnvVar { + monEnvVars := []v1.EnvVar{ + {Name: "ROOK_CEPH_MON_HOST", + ValueFrom: &v1.EnvVarSource{ + SecretKeyRef: &v1.SecretKeySelector{LocalObjectReference: v1.LocalObjectReference{ + Name: "rook-ceph-config"}, + Key: "mon_host"}}}, + {Name: "CEPH_ARGS", Value: "-m $(ROOK_CEPH_MON_HOST)"}, + } + + return append(cephVolumeEnvVar(), monEnvVars...) +} + func (c *Cluster) osdRunFlagTuningOnPVC(osdID int) error { who := fmt.Sprintf("osd.%d", osdID) do := make(map[string]string) diff --git a/pkg/operator/ceph/cluster/osd/spec_test.go b/pkg/operator/ceph/cluster/osd/spec_test.go index 55a92d47c..755ca3452 100644 --- a/pkg/operator/ceph/cluster/osd/spec_test.go +++ b/pkg/operator/ceph/cluster/osd/spec_test.go @@ -395,3 +395,17 @@ func TestCephVolumeEnvVar(t *testing.T) { assert.Equal(t, "DM_DISABLE_UDEV", cvEnv[2].Name) assert.Equal(t, "1", cvEnv[1].Value) } + +func TestOsdActivateEnvVar(t *testing.T) { + osdActivateEnv := osdActivateEnvVar() + assert.Equal(t, 5, len(osdActivateEnv)) + assert.Equal(t, "CEPH_VOLUME_DEBUG", osdActivateEnv[0].Name) + assert.Equal(t, "1", osdActivateEnv[0].Value) + assert.Equal(t, "CEPH_VOLUME_SKIP_RESTORECON", osdActivateEnv[1].Name) + assert.Equal(t, "1", osdActivateEnv[1].Value) + assert.Equal(t, "DM_DISABLE_UDEV", osdActivateEnv[2].Name) + assert.Equal(t, "1", osdActivateEnv[1].Value) + assert.Equal(t, "ROOK_CEPH_MON_HOST", osdActivateEnv[3].Name) + assert.Equal(t, "CEPH_ARGS", osdActivateEnv[4].Name) + assert.Equal(t, "-m $(ROOK_CEPH_MON_HOST)", osdActivateEnv[4].Value) +}