From 4a183d04854496694bf6a3eb0b91c0383590b540 Mon Sep 17 00:00:00 2001 From: Rakshith R Date: Wed, 6 Oct 2021 16:32:30 +0530 Subject: [PATCH] ceph: initialize rbd block pool after creation This is done in order to prevent deadlock when parallel PVC create requests are issued on a new uninitialized rbd block pool due to https://tracker.ceph.com/issues/52537. Fixes: #8696 Signed-off-by: Rakshith R --- pkg/operator/ceph/pool/controller.go | 8 ++++++++ pkg/operator/ceph/pool/controller_test.go | 3 +++ 2 files changed, 11 insertions(+) diff --git a/pkg/operator/ceph/pool/controller.go b/pkg/operator/ceph/pool/controller.go index f0214164aecaa..4d4fb4681a891 100644 --- a/pkg/operator/ceph/pool/controller.go +++ b/pkg/operator/ceph/pool/controller.go @@ -356,6 +356,14 @@ func createPool(context *clusterd.Context, clusterInfo *cephclient.ClusterInfo, return errors.Wrapf(err, "failed to create pool %q", p.Name) } + logger.Infof("initializing pool %q", p.Name) + args := []string{"pool", "init", p.Name} + output, err := cephclient.NewRBDCommand(context, clusterInfo, args).Run() + if err != nil { + return errors.Wrapf(err, "failed to initialize replicated pool %q. %s", p.Name, string(output)) + } + logger.Infof("successfully initialized pool %q", p.Name) + return nil } diff --git a/pkg/operator/ceph/pool/controller_test.go b/pkg/operator/ceph/pool/controller_test.go index c51eaa097db25..91ddf9b71ec9e 100644 --- a/pkg/operator/ceph/pool/controller_test.go +++ b/pkg/operator/ceph/pool/controller_test.go @@ -51,6 +51,9 @@ func TestCreatePool(t *testing.T) { if command == "ceph" && args[1] == "erasure-code-profile" { return `{"k":"2","m":"1","plugin":"jerasure","technique":"reed_sol_van"}`, nil } + if command == "rbd" { + assert.Equal(t, []string{"pool", "init", "mypool"}, args[0:3]) + } return "", nil }, }