From e8267de3c953bd3409459e2848876fd0197478c3 Mon Sep 17 00:00:00 2001 From: Madhu Rajanna Date: Mon, 30 Nov 2020 10:34:58 +0530 Subject: [PATCH] cephfs: fix logic to call ceph fs resize clusterAdditionalInfo map is holding a localClusterState for checking ceph cluster supports resize and subvolumegroup is created or not, currently we are checking if the key is present in a map and localClusterStatelocalClusterState.resizeSupported is set to false to call ceph fs subvolume resize to check command is supported or not, if a structure is initialized all its members are set to default value. so we will never going to check the ceph fs subvolume resize command is supported in backend or not, we are always using ceph fs subvolume create to resize subvolume. in some ceph version ceph fs subvolume create wont work to resize a subvolume. This commit changes the resizeSupported from bool to *bool for proper handling of this scenario. Signed-off-by: Madhu Rajanna (cherry picked from commit a35a835e9c4c753b73b45db760f1a470f5818a1c) --- internal/cephfs/volume.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/internal/cephfs/volume.go b/internal/cephfs/volume.go index d99de0742..1e3b2be4d 100644 --- a/internal/cephfs/volume.go +++ b/internal/cephfs/volume.go @@ -121,7 +121,7 @@ func getSubVolumeInfo(ctx context.Context, volOptions *volumeOptions, cr *util.C type localClusterState struct { // set true if cluster supports resize functionality. - resizeSupported bool + resizeSupported *bool // set true once a subvolumegroup is created // for corresponding cluster. subVolumeGroupCreated bool @@ -201,7 +201,10 @@ func resizeVolume(ctx context.Context, volOptions *volumeOptions, cr *util.Crede } // resize subvolume when either it's supported, or when corresponding // clusterID key was not present. - if clusterAdditionalInfo[volOptions.ClusterID].resizeSupported || !keyPresent { + if clusterAdditionalInfo[volOptions.ClusterID].resizeSupported == nil || *clusterAdditionalInfo[volOptions.ClusterID].resizeSupported { + if clusterAdditionalInfo[volOptions.ClusterID].resizeSupported == nil { + clusterAdditionalInfo[volOptions.ClusterID].resizeSupported = new(bool) + } args := []string{ "fs", "subvolume", @@ -223,7 +226,7 @@ func resizeVolume(ctx context.Context, volOptions *volumeOptions, cr *util.Crede args[:]...) if err == nil { - clusterAdditionalInfo[volOptions.ClusterID].resizeSupported = true + *clusterAdditionalInfo[volOptions.ClusterID].resizeSupported = true return nil } // Incase the error is other than invalid command return error to the caller. @@ -232,7 +235,7 @@ func resizeVolume(ctx context.Context, volOptions *volumeOptions, cr *util.Crede return err } } - clusterAdditionalInfo[volOptions.ClusterID].resizeSupported = false + *clusterAdditionalInfo[volOptions.ClusterID].resizeSupported = false return createVolume(ctx, volOptions, cr, volID, bytesQuota) }