Skip to content

Commit

Permalink
ceph: initialize rbd block pool after creation
Browse files Browse the repository at this point in the history
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 <rar@redhat.com>
  • Loading branch information
Rakshith-R committed Oct 6, 2021
1 parent 00cef45 commit 1724211
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pkg/daemon/ceph/client/pool.go
Expand Up @@ -357,6 +357,12 @@ func CreateECPoolForApp(context *clusterd.Context, clusterInfo *ClusterInfo, poo
return errors.Wrapf(err, "failed to create EC pool %s. %s", poolName, string(output))
}

args = []string{"pool", "init", poolName}
output, err = NewRBDCommand(context, clusterInfo, args).Run()
if err != nil {
return errors.Wrapf(err, "failed to initialize EC pool %q. %s", poolName, string(output))
}

if enableECOverwrite {
if err = SetPoolProperty(context, clusterInfo, poolName, "allow_ec_overwrites", "true"); err != nil {
return errors.Wrapf(err, "failed to allow EC overwrite for pool %s", poolName)
Expand Down Expand Up @@ -406,6 +412,12 @@ func CreateReplicatedPoolForApp(context *clusterd.Context, clusterInfo *ClusterI
return errors.Wrapf(err, "failed to create replicated pool %s. %s", poolName, string(output))
}

args = []string{"pool", "init", poolName}
output, err = NewRBDCommand(context, clusterInfo, args).Run()
if err != nil {
return errors.Wrapf(err, "failed to initialize replicated pool %q. %s", poolName, string(output))
}

if !clusterSpec.IsStretchCluster() {
// the pool is type replicated, set the size for the pool now that it's been created
if err := SetPoolReplicatedSizeProperty(context, clusterInfo, poolName, strconv.FormatUint(uint64(pool.Replicated.Size), 10)); err != nil {
Expand Down
10 changes: 10 additions & 0 deletions pkg/daemon/ceph/client/pool_test.go
Expand Up @@ -82,6 +82,11 @@ func testCreateECPool(t *testing.T, overwrite bool, compressionMode string) {
return "", nil
}
}
if args[0] == "pool" {
assert.Equal(t, "init", args[1])
assert.Equal(t, "mypool", args[2])
return "", nil
}
return "", errors.Errorf("unexpected ceph command %q", args)
}

Expand Down Expand Up @@ -162,6 +167,11 @@ func testCreateReplicaPool(t *testing.T, failureDomain, crushRoot, deviceClass,
}
return "", nil
}
if args[0] == "pool" {
assert.Equal(t, "init", args[1])
assert.Equal(t, "mypool", args[2])
return "", nil
}
return "", errors.Errorf("unexpected ceph command %q", args)
}

Expand Down
8 changes: 8 additions & 0 deletions pkg/operator/ceph/file/filesystem_test.go
Expand Up @@ -79,12 +79,16 @@ func TestValidateSpec(t *testing.T) {
func isBasePoolOperation(fsName, command string, args []string) bool {
if reflect.DeepEqual(args[0:7], []string{"osd", "pool", "create", fsName + "-metadata", "0", "replicated", fsName + "-metadata"}) {
return true
} else if reflect.DeepEqual(args[0:3], []string{"pool", "init", fsName + "-metadata"}) {
return true
} else if reflect.DeepEqual(args[0:5], []string{"osd", "crush", "rule", "create-replicated", fsName + "-metadata"}) {
return true
} else if reflect.DeepEqual(args[0:6], []string{"osd", "pool", "set", fsName + "-metadata", "size", "1"}) {
return true
} else if reflect.DeepEqual(args[0:7], []string{"osd", "pool", "create", fsName + "-data0", "0", "replicated", fsName + "-data0"}) {
return true
} else if reflect.DeepEqual(args[0:3], []string{"pool", "init", fsName + "-data0"}) {
return true
} else if reflect.DeepEqual(args[0:5], []string{"osd", "crush", "rule", "create-replicated", fsName + "-data0"}) {
return true
} else if reflect.DeepEqual(args[0:6], []string{"osd", "pool", "set", fsName + "-data0", "size", "1"}) {
Expand Down Expand Up @@ -165,6 +169,8 @@ func fsExecutor(t *testing.T, fsName, configDir string, multiFS bool, createData
} else if reflect.DeepEqual(args[0:4], []string{"osd", "pool", "create", fsName + "-data1"}) {
*createDataOnePoolCount++
return "", nil
} else if reflect.DeepEqual(args[0:3], []string{"pool", "init", fsName + "-data1"}) {
return "", nil
} else if reflect.DeepEqual(args[0:6], []string{"osd", "pool", "set", fsName + "-data1", "size", "1"}) {
return "", nil
} else if reflect.DeepEqual(args[0:4], []string{"fs", "add_data_pool", fsName, fsName + "-data1"}) {
Expand Down Expand Up @@ -228,6 +234,8 @@ func fsExecutor(t *testing.T, fsName, configDir string, multiFS bool, createData
} else if reflect.DeepEqual(args[0:4], []string{"osd", "pool", "create", fsName + "-data1"}) {
*createDataOnePoolCount++
return "", nil
} else if reflect.DeepEqual(args[0:3], []string{"pool", "init", fsName + "-data1"}) {
return "", nil
} else if reflect.DeepEqual(args[0:6], []string{"osd", "pool", "set", fsName + "-data1", "size", "1"}) {
return "", nil
} else if reflect.DeepEqual(args[0:4], []string{"fs", "add_data_pool", fsName, fsName + "-data1"}) {
Expand Down

0 comments on commit 1724211

Please sign in to comment.