From 5d5bdbbbdae0cf9e6af6c9b0e83d1d20d194e62b Mon Sep 17 00:00:00 2001 From: subhamkrai Date: Wed, 16 Jun 2021 13:39:49 +0530 Subject: [PATCH] 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 --- pkg/daemon/ceph/client/filesystem.go | 8 ++------ pkg/operator/ceph/file/filesystem.go | 5 +---- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/pkg/daemon/ceph/client/filesystem.go b/pkg/daemon/ceph/client/filesystem.go index 3b9819ace..af7d388bd 100644 --- a/pkg/daemon/ceph/client/filesystem.go +++ b/pkg/daemon/ceph/client/filesystem.go @@ -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) diff --git a/pkg/operator/ceph/file/filesystem.go b/pkg/operator/ceph/file/filesystem.go index 888779e87..5e1407c10 100644 --- a/pkg/operator/ceph/file/filesystem.go +++ b/pkg/operator/ceph/file/filesystem.go @@ -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 }