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>
This commit is contained in:
Madhu Rajanna 2020-11-30 10:34:58 +05:30 committed by mergify[bot]
parent a1c8942e2b
commit a35a835e9c

View File

@ -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)
}