From a35a835e9c4c753b73b45db760f1a470f5818a1c 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 --- 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 5309368e3..f534f7411 100644 --- a/internal/cephfs/volume.go +++ b/internal/cephfs/volume.go @@ -121,7 +121,7 @@ func (vo *volumeOptions) getSubVolumeInfo(ctx context.Context, volID volumeID) ( 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 @@ -183,7 +183,10 @@ func (vo *volumeOptions) resizeVolume(ctx context.Context, volID volumeID, bytes } // resize subvolume when either it's supported, or when corresponding // clusterID key was not present. - if clusterAdditionalInfo[vo.ClusterID].resizeSupported || !keyPresent { + if clusterAdditionalInfo[vo.ClusterID].resizeSupported == nil || *clusterAdditionalInfo[vo.ClusterID].resizeSupported { + if clusterAdditionalInfo[vo.ClusterID].resizeSupported == nil { + clusterAdditionalInfo[vo.ClusterID].resizeSupported = new(bool) + } fsa, err := vo.conn.GetFSAdmin() if err != nil { util.ErrorLog(ctx, "could not get FSAdmin, can not resize volume %s:", vo.FsName, err) @@ -192,7 +195,7 @@ func (vo *volumeOptions) resizeVolume(ctx context.Context, volID volumeID, bytes _, err = fsa.ResizeSubVolume(vo.FsName, vo.SubvolumeGroup, string(volID), fsAdmin.ByteCount(bytesQuota), true) if err == nil { - clusterAdditionalInfo[vo.ClusterID].resizeSupported = true + *clusterAdditionalInfo[vo.ClusterID].resizeSupported = true return nil } var invalid fsAdmin.NotImplementedError @@ -202,7 +205,7 @@ func (vo *volumeOptions) resizeVolume(ctx context.Context, volID volumeID, bytes return err } } - clusterAdditionalInfo[vo.ClusterID].resizeSupported = false + *clusterAdditionalInfo[vo.ClusterID].resizeSupported = false return createVolume(ctx, vo, volID, bytesQuota) }