From ff2bc6509f7858ee2118840e2137a46dba7e0d4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Han?= Date: Fri, 25 Jan 2019 17:00:18 +0100 Subject: [PATCH] mon: do not generate nor inject a monmap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Given that we have mon_host and mon_initial_members sections in our ceph.conf, building a monitor map is not needed. During the monitor mkfs a monmap will get generated on the fly based on the section mentioned above. One benefit from that commit is a potential speed improvement as we have removed the container that was generating the map from the monitor initialization sequence. Resolves: https://github.com/rook/rook/issues/2576 Signed-off-by: Sébastien Han --- pkg/operator/ceph/cluster/mon/spec.go | 32 ------------------- pkg/operator/ceph/cluster/mon/spec_test.go | 36 +++++----------------- 2 files changed, 7 insertions(+), 61 deletions(-) diff --git a/pkg/operator/ceph/cluster/mon/spec.go b/pkg/operator/ceph/cluster/mon/spec.go index d64781020..e12b576ca 100644 --- a/pkg/operator/ceph/cluster/mon/spec.go +++ b/pkg/operator/ceph/cluster/mon/spec.go @@ -84,8 +84,6 @@ func (c *Cluster) makeMonPod(monConfig *monConfig, hostname string) *v1.Pod { InitContainers: []v1.Container{ // Config file init performed by Rook c.makeConfigInitContainer(monConfig), - // Ceph monmap init performed by 'monmaptool' - c.makeMonmapInitContainer(monConfig), // mon filesystem init performed by mon daemon c.makeMonFSInitContainer(monConfig), }, @@ -165,35 +163,6 @@ func (c *Cluster) monmapFilePath(monConfig *monConfig) string { ) } -func (c *Cluster) makeMonmapInitContainer(monConfig *monConfig) v1.Container { - // Add mons w/ monmaptool w/ args: [--add ]... - monmapAddMonArgs := []string{} - for _, mon := range c.clusterInfo.Monitors { - monmapAddMonArgs = append(monmapAddMonArgs, "--add", mon.Name, mon.Endpoint) - } - - return v1.Container{ - Name: "monmap-init", - Command: []string{ - monmaptoolCommand, - }, - Args: append( - []string{ - c.monmapFilePath(monConfig), - "--create", - "--clobber", - "--fsid", c.clusterInfo.FSID, - }, - monmapAddMonArgs..., - ), - Image: c.cephVersion.Image, - VolumeMounts: opspec.CephVolumeMounts(), - SecurityContext: podSecurityContext(), - // monmap creation does not require ports to be exposed - Resources: c.resources, - } -} - // args needed for all ceph-mon calls func (c *Cluster) cephMonCommonArgs(monConfig *monConfig) []string { return []string{ @@ -211,7 +180,6 @@ func (c *Cluster) makeMonFSInitContainer(monConfig *monConfig) v1.Container { Args: append( []string{ "--mkfs", - "--monmap", c.monmapFilePath(monConfig), }, c.cephMonCommonArgs(monConfig)..., ), diff --git a/pkg/operator/ceph/cluster/mon/spec_test.go b/pkg/operator/ceph/cluster/mon/spec_test.go index c27e24175..7e801e228 100644 --- a/pkg/operator/ceph/cluster/mon/spec_test.go +++ b/pkg/operator/ceph/cluster/mon/spec_test.go @@ -29,7 +29,7 @@ import ( "github.com/rook/rook/pkg/operator/k8sutil" testop "github.com/rook/rook/pkg/operator/test" "github.com/stretchr/testify/assert" - "k8s.io/api/core/v1" + v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -88,7 +88,7 @@ func testPodSpec(t *testing.T, dataDir string) { assert.Nil(t, test_opceph.VerifyPodLabels("rook-ceph-mon", "ns", "mon", "a", pod.ObjectMeta.Labels)) assert.Equal(t, c.Namespace, pod.ObjectMeta.Labels["mon_cluster"]) - assert.Equal(t, 3, len(pod.Spec.InitContainers)) + assert.Equal(t, 2, len(pod.Spec.InitContainers)) assert.Equal(t, 1, len(pod.Spec.Containers)) // All containers have the same privilege @@ -130,26 +130,6 @@ func testPodSpec(t *testing.T, dataDir string) { "rook-data", cephconfig.DefaultConfigMountName} - // monmap init container - monmapContDev := test_opceph.ContainerTestDefinition{ - Image: &cephImage, - Command: []string{ - "/usr/bin/monmaptool"}, - Args: [][]string{ - {"/var/lib/rook/mon-a/monmap"}, - {"--create"}, - {"--clobber"}, - {"--fsid", c.clusterInfo.FSID}}, - VolumeMountNames: cephVolumeMountNames, - EnvCount: &cephEnvs, - Ports: []v1.ContainerPort{}, - IsPrivileged: &isPrivileged, - } - cont = &pod.Spec.InitContainers[1] - monmapContDev.TestContainer(t, "monmap init", cont, logger) - assert.Equal(t, "100", cont.Resources.Limits.Cpu().String()) - assert.Equal(t, "1337", cont.Resources.Requests.Memory().String()) - // mon fs init container monFsContDev := test_opceph.ContainerTestDefinition{ Image: &cephImage, @@ -157,15 +137,14 @@ func testPodSpec(t *testing.T, dataDir string) { "ceph-mon"}, Args: append( monCommonExpectedArgs(name, c), - []string{"--mkfs"}, - []string{"--monmap", "/var/lib/rook/mon-a/monmap"}), + []string{"--mkfs"}), VolumeMountNames: cephVolumeMountNames, EnvCount: &cephEnvs, Ports: []v1.ContainerPort{}, IsPrivileged: &isPrivileged, } - cont = &pod.Spec.InitContainers[2] - monFsContDev.TestContainer(t, "monmap init", cont, logger) + cont = &pod.Spec.InitContainers[1] + monFsContDev.TestContainer(t, "mon mkfs init", cont, logger) assert.Equal(t, "100", cont.Resources.Limits.Cpu().String()) assert.Equal(t, "1337", cont.Resources.Requests.Memory().String()) @@ -187,7 +166,7 @@ func testPodSpec(t *testing.T, dataDir string) { IsPrivileged: &isPrivileged, } cont = &pod.Spec.Containers[0] - monDaemonContDev.TestContainer(t, "monmap init", cont, logger) + monDaemonContDev.TestContainer(t, "mon init", cont, logger) assert.Equal(t, "100", cont.Resources.Limits.Cpu().String()) assert.Equal(t, "1337", cont.Resources.Requests.Memory().String()) @@ -196,8 +175,7 @@ func testPodSpec(t *testing.T, dataDir string) { VolumesSpec: &testop.VolumesSpec{Moniker: "mon pod volumes", Volumes: pod.Spec.Volumes}, MountsSpecItems: []*testop.MountsSpec{ {Moniker: "mon config init mounts", Mounts: pod.Spec.InitContainers[0].VolumeMounts}, - {Moniker: "mon monmap init mounts", Mounts: pod.Spec.InitContainers[1].VolumeMounts}, - {Moniker: "mon fs init mounts", Mounts: pod.Spec.InitContainers[2].VolumeMounts}, + {Moniker: "mon fs init mounts", Mounts: pod.Spec.InitContainers[1].VolumeMounts}, {Moniker: "mon daemon mounts", Mounts: pod.Spec.Containers[0].VolumeMounts}}, } volsMountsTestDef.TestMountsMatchVolumes(t)