ceph: remove --force when creating filesystem

we should not use --force when creating filesystem(fs)
as it will recreate fs which will leads to data loss
when `preserveFilesystemOnDelete` is set to 'true'.

this commit removes --force argument when create fs.

Signed-off-by: subhamkrai <srai@redhat.com>
This commit is contained in:
subhamkrai committed 2021-06-16 13:39:49 +05:30
1 parent 02d84f2c0f
commit 5d5bdbbbda
2 files changed
+3 -10

No files matched your search

+2 -6
View File
@@ -132,7 +132,7 @@ func AllowStandbyReplay(context *clusterd.Context, clusterInfo *ClusterInfo, fsN
}
// CreateFilesystem performs software configuration steps for Ceph to provide a new filesystem.
func CreateFilesystem(context *clusterd.Context, clusterInfo *ClusterInfo, name, metadataPool string, dataPools []string, force bool) error {
func CreateFilesystem(context *clusterd.Context, clusterInfo *ClusterInfo, name, metadataPool string, dataPools []string) error {
if len(dataPools) == 0 {
return errors.New("at least one data pool is required")
}
@@ -152,11 +152,7 @@ func CreateFilesystem(context *clusterd.Context, clusterInfo *ClusterInfo, name,
// create the filesystem
args := []string{"fs", "new", name, metadataPool, dataPools[0]}
// Force to use pre-existing pools
if force {
args = append(args, "--force")
logger.Infof("Filesystem %q will reuse pre-existing pools", name)
}
_, err = NewCephCommand(context, clusterInfo, args).Run()
if err != nil {
return errors.Wrapf(err, "failed enabling ceph fs %q", name)
+1 -4
View File
@@ -247,10 +247,8 @@ func (f *Filesystem) doFilesystemCreate(context *clusterd.Context, clusterInfo *
reversedPoolMap[value] = key
}
poolsCreated := false
metadataPoolName := generateMetaDataPoolName(f)
if _, poolFound := reversedPoolMap[metadataPoolName]; !poolFound {
poolsCreated = true
err = cephclient.CreatePoolWithProfile(context, clusterInfo, clusterSpec, metadataPoolName, spec.MetadataPool, "")
if err != nil {
return errors.Wrapf(err, "failed to create metadata pool %q", metadataPoolName)
@@ -261,7 +259,6 @@ func (f *Filesystem) doFilesystemCreate(context *clusterd.Context, clusterInfo *
for i, pool := range spec.DataPools {
poolName := dataPoolNames[i]
if _, poolFound := reversedPoolMap[poolName]; !poolFound {
poolsCreated = true
err = cephclient.CreatePoolWithProfile(context, clusterInfo, clusterSpec, poolName, pool, "")
if err != nil {
return errors.Wrapf(err, "failed to create data pool %q", poolName)
@@ -277,7 +274,7 @@ func (f *Filesystem) doFilesystemCreate(context *clusterd.Context, clusterInfo *
// create the filesystem ('fs new' needs to be forced in order to reuse pre-existing pools)
// if only one pool is created new it won't work (to avoid inconsistencies).
if err := cephclient.CreateFilesystem(context, clusterInfo, f.Name, metadataPoolName, dataPoolNames, !poolsCreated); err != nil {
if err := cephclient.CreateFilesystem(context, clusterInfo, f.Name, metadataPoolName, dataPoolNames); err != nil {
return err
}