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 <madhupr007@gmail.com>
(cherry picked from commit a35a835e9c)
This commit is contained in:
Madhu Rajanna 2020-11-30 10:34:58 +05:30 committed by mergify[bot]
parent 75e06f9581
commit e8267de3c9

View File

@ -121,7 +121,7 @@ func getSubVolumeInfo(ctx context.Context, volOptions *volumeOptions, cr *util.C
type localClusterState struct { type localClusterState struct {
// set true if cluster supports resize functionality. // set true if cluster supports resize functionality.
resizeSupported bool resizeSupported *bool
// set true once a subvolumegroup is created // set true once a subvolumegroup is created
// for corresponding cluster. // for corresponding cluster.
subVolumeGroupCreated bool 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 // resize subvolume when either it's supported, or when corresponding
// clusterID key was not present. // 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{ args := []string{
"fs", "fs",
"subvolume", "subvolume",
@ -223,7 +226,7 @@ func resizeVolume(ctx context.Context, volOptions *volumeOptions, cr *util.Crede
args[:]...) args[:]...)
if err == nil { if err == nil {
clusterAdditionalInfo[volOptions.ClusterID].resizeSupported = true *clusterAdditionalInfo[volOptions.ClusterID].resizeSupported = true
return nil return nil
} }
// Incase the error is other than invalid command return error to the caller. // 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 return err
} }
} }
clusterAdditionalInfo[volOptions.ClusterID].resizeSupported = false *clusterAdditionalInfo[volOptions.ClusterID].resizeSupported = false
return createVolume(ctx, volOptions, cr, volID, bytesQuota) return createVolume(ctx, volOptions, cr, volID, bytesQuota)
} }