mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-22 06:10:22 +00:00
cleanup: cephfs resize code cleanup
The ceph fs subvolume resize support is available in all the active ceph releases. Hence removing the code to check the supportability of the feature. Signed-off-by: karthik-us <ksubrahm@redhat.com>
This commit is contained in:
parent
5d57fd3f70
commit
31aeaf7e5b
@ -199,15 +199,13 @@ func (s *subVolumeClient) GetSubVolumeInfo(ctx context.Context) (*Subvolume, err
|
|||||||
type operationState int64
|
type operationState int64
|
||||||
|
|
||||||
const (
|
const (
|
||||||
unknown operationState = iota
|
supported operationState = iota
|
||||||
supported
|
|
||||||
unsupported
|
unsupported
|
||||||
)
|
)
|
||||||
|
|
||||||
type localClusterState struct {
|
type localClusterState struct {
|
||||||
// set the enum value i.e., unknown, supported,
|
// set the enum value i.e., supported or
|
||||||
// unsupported as per the state of the cluster.
|
// unsupported as per the state of the cluster.
|
||||||
resizeState operationState
|
|
||||||
subVolMetadataState operationState
|
subVolMetadataState operationState
|
||||||
subVolSnapshotMetadataState operationState
|
subVolSnapshotMetadataState operationState
|
||||||
}
|
}
|
||||||
@ -268,39 +266,21 @@ func (s *subVolumeClient) ExpandVolume(ctx context.Context, bytesQuota int64) er
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// ResizeVolume will try to use ceph fs subvolume resize command to resize the
|
// ResizeVolume will use the ceph fs subvolume resize command to resize the
|
||||||
// subvolume. If the command is not available as a fallback it will use
|
// subvolume.
|
||||||
// CreateVolume to resize the subvolume.
|
|
||||||
func (s *subVolumeClient) ResizeVolume(ctx context.Context, bytesQuota int64) error {
|
func (s *subVolumeClient) ResizeVolume(ctx context.Context, bytesQuota int64) error {
|
||||||
newLocalClusterState(s.clusterID)
|
fsa, err := s.conn.GetFSAdmin()
|
||||||
// resize subvolume when either it's supported, or when corresponding
|
if err != nil {
|
||||||
// clusterID key was not present.
|
log.ErrorLog(ctx, "could not get FSAdmin, can not resize volume %s:", s.FsName, err)
|
||||||
if clusterAdditionalInfo[s.clusterID].resizeState == unknown ||
|
|
||||||
clusterAdditionalInfo[s.clusterID].resizeState == supported {
|
|
||||||
fsa, err := s.conn.GetFSAdmin()
|
|
||||||
if err != nil {
|
|
||||||
log.ErrorLog(ctx, "could not get FSAdmin, can not resize volume %s:", s.FsName, err)
|
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
_, err = fsa.ResizeSubVolume(s.FsName, s.SubvolumeGroup, s.VolID, fsAdmin.ByteCount(bytesQuota), true)
|
_, err = fsa.ResizeSubVolume(s.FsName, s.SubvolumeGroup, s.VolID, fsAdmin.ByteCount(bytesQuota), true)
|
||||||
if err == nil {
|
if err != nil {
|
||||||
clusterAdditionalInfo[s.clusterID].resizeState = supported
|
log.ErrorLog(ctx, "failed to resize subvolume %s in fs %s: %s", s.VolID, s.FsName, err)
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
var invalid fsAdmin.NotImplementedError
|
|
||||||
// In case the error is other than invalid command return error to the caller.
|
|
||||||
if !errors.As(err, &invalid) {
|
|
||||||
log.ErrorLog(ctx, "failed to resize subvolume %s in fs %s: %s", s.VolID, s.FsName, err)
|
|
||||||
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
clusterAdditionalInfo[s.clusterID].resizeState = unsupported
|
|
||||||
s.Size = bytesQuota
|
|
||||||
|
|
||||||
return s.CreateVolume(ctx)
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// PurgSubVolume removes the subvolume.
|
// PurgSubVolume removes the subvolume.
|
||||||
|
Loading…
Reference in New Issue
Block a user