internal: reformat long lines in internal/cephfs package to 120 chars

We have many declarations and invocations..etc
with long lines which are very difficult to follow while doing
code reading. This address the issues in 'internal/cephfs' package to
restrict the line length to 120 chars.

Signed-off-by: Humble Chirammal <hchiramm@redhat.com>
This commit is contained in:
Humble Chirammal 2021-06-25 15:48:59 +05:30 committed by mergify[bot]
parent c2cda4909b
commit 0d432be5bf
10 changed files with 190 additions and 45 deletions

View File

@ -134,7 +134,10 @@ func createCloneFromSubvolume(ctx context.Context, volID, cloneID volumeID, volO
return nil
}
func cleanupCloneFromSubvolumeSnapshot(ctx context.Context, volID, cloneID volumeID, parentVolOpt *volumeOptions) error {
func cleanupCloneFromSubvolumeSnapshot(
ctx context.Context,
volID, cloneID volumeID,
parentVolOpt *volumeOptions) error {
// snapshot name is same as clone name as we need a name which can be
// identified during PVC-PVC cloning.
snapShotID := cloneID
@ -167,7 +170,11 @@ func isCloneRetryError(err error) bool {
return errors.Is(err, ErrCloneInProgress) || errors.Is(err, ErrClonePending)
}
func createCloneFromSnapshot(ctx context.Context, parentVolOpt, volOptions *volumeOptions, vID *volumeIdentifier, sID *snapshotIdentifier) error {
func createCloneFromSnapshot(
ctx context.Context,
parentVolOpt, volOptions *volumeOptions,
vID *volumeIdentifier,
sID *snapshotIdentifier) error {
snapID := volumeID(sID.FsSnapshotName)
err := parentVolOpt.cloneSnapshot(ctx, volumeID(sID.FsSubvolName), snapID, volumeID(vID.FsSubvolName), volOptions)
if err != nil {
@ -211,7 +218,12 @@ func createCloneFromSnapshot(ctx context.Context, parentVolOpt, volOptions *volu
func (vo *volumeOptions) getCloneState(ctx context.Context, volID volumeID) (cephFSCloneState, error) {
fsa, err := vo.conn.GetFSAdmin()
if err != nil {
util.ErrorLog(ctx, "could not get FSAdmin, can get clone status for volume %s with ID %s: %v", vo.FsName, string(volID), err)
util.ErrorLog(
ctx,
"could not get FSAdmin, can get clone status for volume %s with ID %s: %v",
vo.FsName,
string(volID),
err)
return cephFSCloneError, err
}

View File

@ -77,7 +77,12 @@ func (cs *ControllerServer) createBackingVolume(
return status.Error(codes.Aborted, err.Error())
}
defer cs.OperationLocks.ReleaseCloneLock(pvID.VolumeID)
err = createCloneFromSubvolume(ctx, volumeID(pvID.FsSubvolName), volumeID(vID.FsSubvolName), volOptions, parentVolOpt)
err = createCloneFromSubvolume(
ctx,
volumeID(pvID.FsSubvolName),
volumeID(vID.FsSubvolName),
volOptions,
parentVolOpt)
if err != nil {
util.ErrorLog(ctx, "failed to create clone from subvolume %s: %v", volumeID(pvID.FsSubvolName), err)
return err
@ -92,7 +97,10 @@ func (cs *ControllerServer) createBackingVolume(
return nil
}
func checkContentSource(ctx context.Context, req *csi.CreateVolumeRequest, cr *util.Credentials) (*volumeOptions, *volumeIdentifier, *snapshotIdentifier, error) {
func checkContentSource(
ctx context.Context,
req *csi.CreateVolumeRequest,
cr *util.Credentials) (*volumeOptions, *volumeIdentifier, *snapshotIdentifier, error) {
if req.VolumeContentSource == nil {
return nil, nil, nil, nil
}
@ -126,7 +134,9 @@ func checkContentSource(ctx context.Context, req *csi.CreateVolumeRequest, cr *u
// CreateVolume creates a reservation and the volume in backend, if it is not already present.
// nolint:gocognit,gocyclo,nestif // TODO: reduce complexity
func (cs *ControllerServer) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest) (*csi.CreateVolumeResponse, error) {
func (cs *ControllerServer) CreateVolume(
ctx context.Context,
req *csi.CreateVolumeRequest) (*csi.CreateVolumeResponse, error) {
if err := cs.validateCreateVolumeRequest(req); err != nil {
util.ErrorLog(ctx, "CreateVolumeRequest validation failed: %v", err)
return nil, err
@ -293,7 +303,9 @@ func (cs *ControllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol
}
// DeleteVolume deletes the volume in backend and its reservation.
func (cs *ControllerServer) DeleteVolume(ctx context.Context, req *csi.DeleteVolumeRequest) (*csi.DeleteVolumeResponse, error) {
func (cs *ControllerServer) DeleteVolume(
ctx context.Context,
req *csi.DeleteVolumeRequest) (*csi.DeleteVolumeResponse, error) {
if err := cs.validateDeleteVolumeRequest(); err != nil {
util.ErrorLog(ctx, "DeleteVolumeRequest validation failed: %v", err)
return nil, err
@ -408,7 +420,9 @@ func (cs *ControllerServer) ValidateVolumeCapabilities(
}
// ControllerExpandVolume expands CephFS Volumes on demand based on resizer request.
func (cs *ControllerServer) ControllerExpandVolume(ctx context.Context, req *csi.ControllerExpandVolumeRequest) (*csi.ControllerExpandVolumeResponse, error) {
func (cs *ControllerServer) ControllerExpandVolume(
ctx context.Context,
req *csi.ControllerExpandVolumeRequest) (*csi.ControllerExpandVolumeResponse, error) {
if err := cs.validateExpandVolumeRequest(req); err != nil {
util.ErrorLog(ctx, "ControllerExpandVolumeRequest validation failed: %v", err)
return nil, err
@ -460,7 +474,9 @@ func (cs *ControllerServer) ControllerExpandVolume(ctx context.Context, req *csi
// CreateSnapshot creates the snapshot in backend and stores metadata
// in store
// nolint:gocyclo // golangci-lint did not catch this earlier, needs to get fixed late
func (cs *ControllerServer) CreateSnapshot(ctx context.Context, req *csi.CreateSnapshotRequest) (*csi.CreateSnapshotResponse, error) {
func (cs *ControllerServer) CreateSnapshot(
ctx context.Context,
req *csi.CreateSnapshotRequest) (*csi.CreateSnapshotResponse, error) {
if err := cs.validateSnapshotReq(ctx, req); err != nil {
return nil, err
}
@ -507,7 +523,11 @@ func (cs *ControllerServer) CreateSnapshot(ctx context.Context, req *csi.CreateS
defer parentVolOptions.Destroy()
if clusterData.ClusterID != parentVolOptions.ClusterID {
return nil, status.Errorf(codes.InvalidArgument, "requested cluster id %s not matching subvolume cluster id %s", clusterData.ClusterID, parentVolOptions.ClusterID)
return nil, status.Errorf(
codes.InvalidArgument,
"requested cluster id %s not matching subvolume cluster id %s",
clusterData.ClusterID,
parentVolOptions.ClusterID)
}
cephfsSnap, genSnapErr := genSnapFromOptions(ctx, req)
@ -538,7 +558,9 @@ func (cs *ControllerServer) CreateSnapshot(ctx context.Context, req *csi.CreateS
// support it or not, its safe to evaluat as the filtering
// is already done from getSubVolumeInfo() and send out the error here.
if errors.Is(err, ErrInvalidCommand) {
return nil, status.Error(codes.FailedPrecondition, "subvolume info command not supported in current ceph cluster")
return nil, status.Error(
codes.FailedPrecondition,
"subvolume info command not supported in current ceph cluster")
}
if sid != nil {
errDefer := undoSnapReservation(ctx, parentVolOptions, *sid, snapName, cr)
@ -639,7 +661,8 @@ func doSnapshot(ctx context.Context, volOpt *volumeOptions, subvolumeName, snaps
}
func (cs *ControllerServer) validateSnapshotReq(ctx context.Context, req *csi.CreateSnapshotRequest) error {
if err := cs.Driver.ValidateControllerServiceRequest(csi.ControllerServiceCapability_RPC_CREATE_DELETE_SNAPSHOT); err != nil {
if err := cs.Driver.ValidateControllerServiceRequest(
csi.ControllerServiceCapability_RPC_CREATE_DELETE_SNAPSHOT); err != nil {
util.ErrorLog(ctx, "invalid create snapshot req: %v", protosanitizer.StripSecrets(req))
return err
}
@ -657,8 +680,11 @@ func (cs *ControllerServer) validateSnapshotReq(ctx context.Context, req *csi.Cr
// DeleteSnapshot deletes the snapshot in backend and removes the
// snapshot metadata from store.
func (cs *ControllerServer) DeleteSnapshot(ctx context.Context, req *csi.DeleteSnapshotRequest) (*csi.DeleteSnapshotResponse, error) {
if err := cs.Driver.ValidateControllerServiceRequest(csi.ControllerServiceCapability_RPC_CREATE_DELETE_SNAPSHOT); err != nil {
func (cs *ControllerServer) DeleteSnapshot(
ctx context.Context,
req *csi.DeleteSnapshotRequest) (*csi.DeleteSnapshotResponse, error) {
if err := cs.Driver.ValidateControllerServiceRequest(
csi.ControllerServiceCapability_RPC_CREATE_DELETE_SNAPSHOT); err != nil {
util.ErrorLog(ctx, "invalid delete snapshot req: %v", protosanitizer.StripSecrets(req))
return nil, err
}

View File

@ -136,7 +136,11 @@ func checkVolExists(ctx context.Context,
// If the subvolume is not present, cleanup the stale snapshot
// created for clone.
if parentVolOpt != nil && pvID != nil {
err = cleanupCloneFromSubvolumeSnapshot(ctx, volumeID(pvID.FsSubvolName), volumeID(vid.FsSubvolName), parentVolOpt)
err = cleanupCloneFromSubvolumeSnapshot(
ctx,
volumeID(pvID.FsSubvolName),
volumeID(vid.FsSubvolName),
parentVolOpt)
if err != nil {
return nil, err
}
@ -165,7 +169,11 @@ func checkVolExists(ctx context.Context,
vid.VolumeID, vid.FsSubvolName, volOptions.RequestName)
if parentVolOpt != nil && pvID != nil {
err = cleanupCloneFromSubvolumeSnapshot(ctx, volumeID(pvID.FsSubvolName), volumeID(vid.FsSubvolName), parentVolOpt)
err = cleanupCloneFromSubvolumeSnapshot(
ctx,
volumeID(pvID.FsSubvolName),
volumeID(vid.FsSubvolName),
parentVolOpt)
if err != nil {
return nil, err
}
@ -175,7 +183,11 @@ func checkVolExists(ctx context.Context,
}
// undoVolReservation is a helper routine to undo a name reservation for a CSI VolumeName.
func undoVolReservation(ctx context.Context, volOptions *volumeOptions, vid volumeIdentifier, secret map[string]string) error {
func undoVolReservation(
ctx context.Context,
volOptions *volumeOptions,
vid volumeIdentifier,
secret map[string]string) error {
cr, err := util.NewAdminCredentials(secret)
if err != nil {
return err
@ -259,7 +271,12 @@ func reserveVol(ctx context.Context, volOptions *volumeOptions, secret map[strin
// reserveSnap is a helper routine to request a UUID reservation for the CSI SnapName and,
// to generate the snapshot identifier for the reserved UUID.
func reserveSnap(ctx context.Context, volOptions *volumeOptions, parentSubVolName string, snap *cephfsSnapshot, cr *util.Credentials) (*snapshotIdentifier, error) {
func reserveSnap(
ctx context.Context,
volOptions *volumeOptions,
parentSubVolName string,
snap *cephfsSnapshot,
cr *util.Credentials) (*snapshotIdentifier, error) {
var (
vid snapshotIdentifier
imageUUID string
@ -295,7 +312,12 @@ func reserveSnap(ctx context.Context, volOptions *volumeOptions, parentSubVolNam
}
// undoSnapReservation is a helper routine to undo a name reservation for a CSI SnapshotName.
func undoSnapReservation(ctx context.Context, volOptions *volumeOptions, vid snapshotIdentifier, snapName string, cr *util.Credentials) error {
func undoSnapReservation(
ctx context.Context,
volOptions *volumeOptions,
vid snapshotIdentifier,
snapName string,
cr *util.Credentials) error {
// Connect to cephfs' default radosNamespace (csi)
j, err := snapJournal.Connect(volOptions.Monitors, radosNamespace, cr)
if err != nil {

View File

@ -31,7 +31,9 @@ type IdentityServer struct {
}
// GetPluginCapabilities returns available capabilities of the ceph driver.
func (is *IdentityServer) GetPluginCapabilities(ctx context.Context, req *csi.GetPluginCapabilitiesRequest) (*csi.GetPluginCapabilitiesResponse, error) {
func (is *IdentityServer) GetPluginCapabilities(
ctx context.Context,
req *csi.GetPluginCapabilitiesRequest) (*csi.GetPluginCapabilitiesResponse, error) {
return &csi.GetPluginCapabilitiesResponse{
Capabilities: []*csi.PluginCapability{
{

View File

@ -67,7 +67,9 @@ func getCredentialsForVolume(volOptions *volumeOptions, req *csi.NodeStageVolume
}
// NodeStageVolume mounts the volume to a staging path on the node.
func (ns *NodeServer) NodeStageVolume(ctx context.Context, req *csi.NodeStageVolumeRequest) (*csi.NodeStageVolumeResponse, error) {
func (ns *NodeServer) NodeStageVolume(
ctx context.Context,
req *csi.NodeStageVolumeRequest) (*csi.NodeStageVolumeResponse, error) {
var (
volOptions *volumeOptions
)
@ -179,14 +181,25 @@ func (*NodeServer) mount(ctx context.Context, volOptions *volumeOptions, req *cs
err)
return status.Error(codes.Internal, err.Error())
}
if !csicommon.MountOptionContains(kernelMountOptions, readOnly) && !csicommon.MountOptionContains(fuseMountOptions, readOnly) {
if !csicommon.MountOptionContains(kernelMountOptions, readOnly) &&
!csicommon.MountOptionContains(fuseMountOptions, readOnly) {
// #nosec - allow anyone to write inside the stagingtarget path
err = os.Chmod(stagingTargetPath, 0777)
if err != nil {
util.ErrorLog(ctx, "failed to change stagingtarget path %s permission for volume %s: %v", stagingTargetPath, volID, err)
util.ErrorLog(
ctx,
"failed to change stagingtarget path %s permission for volume %s: %v",
stagingTargetPath,
volID,
err)
uErr := unmountVolume(ctx, stagingTargetPath)
if uErr != nil {
util.ErrorLog(ctx, "failed to umount stagingtarget path %s for volume %s: %v", stagingTargetPath, volID, uErr)
util.ErrorLog(
ctx,
"failed to umount stagingtarget path %s for volume %s: %v",
stagingTargetPath,
volID,
uErr)
}
return status.Error(codes.Internal, err.Error())
}
@ -196,7 +209,9 @@ func (*NodeServer) mount(ctx context.Context, volOptions *volumeOptions, req *cs
// NodePublishVolume mounts the volume mounted to the staging path to the target
// path.
func (ns *NodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublishVolumeRequest) (*csi.NodePublishVolumeResponse, error) {
func (ns *NodeServer) NodePublishVolume(
ctx context.Context,
req *csi.NodePublishVolumeRequest) (*csi.NodePublishVolumeResponse, error) {
mountOptions := []string{"bind", "_netdev"}
if err := util.ValidateNodePublishVolumeRequest(req); err != nil {
return nil, err
@ -249,7 +264,9 @@ func (ns *NodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublis
}
// NodeUnpublishVolume unmounts the volume from the target path.
func (ns *NodeServer) NodeUnpublishVolume(ctx context.Context, req *csi.NodeUnpublishVolumeRequest) (*csi.NodeUnpublishVolumeResponse, error) {
func (ns *NodeServer) NodeUnpublishVolume(
ctx context.Context,
req *csi.NodeUnpublishVolumeRequest) (*csi.NodeUnpublishVolumeResponse, error) {
var err error
if err = util.ValidateNodeUnpublishVolumeRequest(req); err != nil {
return nil, err
@ -296,7 +313,9 @@ func (ns *NodeServer) NodeUnpublishVolume(ctx context.Context, req *csi.NodeUnpu
}
// NodeUnstageVolume unstages the volume from the staging path.
func (ns *NodeServer) NodeUnstageVolume(ctx context.Context, req *csi.NodeUnstageVolumeRequest) (*csi.NodeUnstageVolumeResponse, error) {
func (ns *NodeServer) NodeUnstageVolume(
ctx context.Context,
req *csi.NodeUnstageVolumeRequest) (*csi.NodeUnstageVolumeResponse, error) {
var err error
if err = util.ValidateNodeUnstageVolumeRequest(req); err != nil {
return nil, err
@ -334,7 +353,9 @@ func (ns *NodeServer) NodeUnstageVolume(ctx context.Context, req *csi.NodeUnstag
}
// NodeGetCapabilities returns the supported capabilities of the node server.
func (ns *NodeServer) NodeGetCapabilities(ctx context.Context, req *csi.NodeGetCapabilitiesRequest) (*csi.NodeGetCapabilitiesResponse, error) {
func (ns *NodeServer) NodeGetCapabilities(
ctx context.Context,
req *csi.NodeGetCapabilitiesRequest) (*csi.NodeGetCapabilitiesResponse, error) {
return &csi.NodeGetCapabilitiesResponse{
Capabilities: []*csi.NodeServiceCapability{
{
@ -356,7 +377,9 @@ func (ns *NodeServer) NodeGetCapabilities(ctx context.Context, req *csi.NodeGetC
}
// NodeGetVolumeStats returns volume stats.
func (ns *NodeServer) NodeGetVolumeStats(ctx context.Context, req *csi.NodeGetVolumeStatsRequest) (*csi.NodeGetVolumeStatsResponse, error) {
func (ns *NodeServer) NodeGetVolumeStats(
ctx context.Context,
req *csi.NodeGetVolumeStatsRequest) (*csi.NodeGetVolumeStatsResponse, error) {
var err error
targetPath := req.GetVolumePath()
if targetPath == "" {

View File

@ -100,7 +100,13 @@ func (vo *volumeOptions) getSnapshotInfo(ctx context.Context, snapID, volID volu
if errors.Is(err, rados.ErrNotFound) {
return snap, ErrSnapNotFound
}
util.ErrorLog(ctx, "failed to get subvolume snapshot info %s %s in fs %s with error %s", string(volID), string(snapID), vo.FsName, err)
util.ErrorLog(
ctx,
"failed to get subvolume snapshot info %s %s in fs %s with error %s",
string(volID),
string(snapID),
vo.FsName,
err)
return snap, err
}
snap.CreatedAt = info.CreatedAt.Time
@ -127,7 +133,13 @@ func (vo *volumeOptions) protectSnapshot(ctx context.Context, snapID, volID volu
if errors.Is(err, rados.ErrObjectExists) {
return nil
}
util.ErrorLog(ctx, "failed to protect subvolume snapshot %s %s in fs %s with error: %s", string(volID), string(snapID), vo.FsName, err)
util.ErrorLog(
ctx,
"failed to protect subvolume snapshot %s %s in fs %s with error: %s",
string(volID),
string(snapID),
vo.FsName,
err)
return err
}
return nil
@ -153,13 +165,23 @@ func (vo *volumeOptions) unprotectSnapshot(ctx context.Context, snapID, volID vo
if errors.Is(err, rados.ErrObjectExists) {
return nil
}
util.ErrorLog(ctx, "failed to unprotect subvolume snapshot %s %s in fs %s with error: %s", string(volID), string(snapID), vo.FsName, err)
util.ErrorLog(
ctx,
"failed to unprotect subvolume snapshot %s %s in fs %s with error: %s",
string(volID),
string(snapID),
vo.FsName,
err)
return err
}
return nil
}
func (vo *volumeOptions) cloneSnapshot(ctx context.Context, volID, snapID, cloneID volumeID, cloneVolOptions *volumeOptions) error {
func (vo *volumeOptions) cloneSnapshot(
ctx context.Context,
volID, snapID, cloneID volumeID,
cloneVolOptions *volumeOptions,
) error {
fsa, err := vo.conn.GetFSAdmin()
if err != nil {
util.ErrorLog(ctx, "could not get FSAdmin: %s", err)
@ -174,7 +196,14 @@ func (vo *volumeOptions) cloneSnapshot(ctx context.Context, volID, snapID, clone
err = fsa.CloneSubVolumeSnapshot(vo.FsName, vo.SubvolumeGroup, string(volID), string(snapID), string(cloneID), co)
if err != nil {
util.ErrorLog(ctx, "failed to clone subvolume snapshot %s %s in fs %s with error: %s", string(volID), string(snapID), string(cloneID), vo.FsName, err)
util.ErrorLog(
ctx,
"failed to clone subvolume snapshot %s %s in fs %s with error: %s",
string(volID),
string(snapID),
string(cloneID),
vo.FsName,
err)
if errors.Is(err, rados.ErrNotFound) {
return ErrVolumeNotFound
}

View File

@ -39,7 +39,8 @@ func execCommandErr(ctx context.Context, program string, args ...string) error {
// Controller service request validation.
func (cs *ControllerServer) validateCreateVolumeRequest(req *csi.CreateVolumeRequest) error {
if err := cs.Driver.ValidateControllerServiceRequest(csi.ControllerServiceCapability_RPC_CREATE_DELETE_VOLUME); err != nil {
if err := cs.Driver.ValidateControllerServiceRequest(
csi.ControllerServiceCapability_RPC_CREATE_DELETE_VOLUME); err != nil {
return fmt.Errorf("invalid CreateVolumeRequest: %w", err)
}
@ -94,7 +95,8 @@ func (cs *ControllerServer) validateCreateVolumeRequest(req *csi.CreateVolumeReq
}
func (cs *ControllerServer) validateDeleteVolumeRequest() error {
if err := cs.Driver.ValidateControllerServiceRequest(csi.ControllerServiceCapability_RPC_CREATE_DELETE_VOLUME); err != nil {
if err := cs.Driver.ValidateControllerServiceRequest(
csi.ControllerServiceCapability_RPC_CREATE_DELETE_VOLUME); err != nil {
return fmt.Errorf("invalid DeleteVolumeRequest: %w", err)
}

View File

@ -157,7 +157,12 @@ func createVolume(ctx context.Context, volOptions *volumeOptions, volID volumeID
opts := fsAdmin.SubVolumeGroupOptions{}
err = ca.CreateSubVolumeGroup(volOptions.FsName, volOptions.SubvolumeGroup, &opts)
if err != nil {
util.ErrorLog(ctx, "failed to create subvolume group %s, for the vol %s: %s", volOptions.SubvolumeGroup, string(volID), err)
util.ErrorLog(
ctx,
"failed to create subvolume group %s, for the vol %s: %s",
volOptions.SubvolumeGroup,
string(volID),
err)
return err
}
util.DebugLog(ctx, "cephfs: created subvolume group %s", volOptions.SubvolumeGroup)

View File

@ -195,7 +195,11 @@ func mountFuse(ctx context.Context, mountPoint string, cr *util.Credentials, vol
return nil
}
func (m *fuseMounter) mount(ctx context.Context, mountPoint string, cr *util.Credentials, volOptions *volumeOptions) error {
func (m *fuseMounter) mount(
ctx context.Context,
mountPoint string,
cr *util.Credentials,
volOptions *volumeOptions) error {
if err := util.CreateMountPoint(mountPoint); err != nil {
return err
}
@ -234,7 +238,11 @@ func mountKernel(ctx context.Context, mountPoint string, cr *util.Credentials, v
return err
}
func (m *kernelMounter) mount(ctx context.Context, mountPoint string, cr *util.Credentials, volOptions *volumeOptions) error {
func (m *kernelMounter) mount(
ctx context.Context,
mountPoint string,
cr *util.Credentials,
volOptions *volumeOptions) error {
if err := util.CreateMountPoint(mountPoint); err != nil {
return err
}

View File

@ -251,7 +251,10 @@ func newVolumeOptions(ctx context.Context, requestName string, req *csi.CreateVo
// newVolumeOptionsFromVolID generates a new instance of volumeOptions and volumeIdentifier
// from the provided CSI VolumeID.
func newVolumeOptionsFromVolID(ctx context.Context, volID string, volOpt, secrets map[string]string) (*volumeOptions, *volumeIdentifier, error) {
func newVolumeOptionsFromVolID(
ctx context.Context,
volID string,
volOpt, secrets map[string]string) (*volumeOptions, *volumeIdentifier, error) {
var (
vi util.CSIIdentifier
volOptions volumeOptions
@ -359,7 +362,9 @@ func newVolumeOptionsFromVolID(ctx context.Context, volID string, volOpt, secret
// newVolumeOptionsFromMonitorList generates a new instance of volumeOptions and
// volumeIdentifier from the provided CSI volume context.
func newVolumeOptionsFromMonitorList(volID string, options, secrets map[string]string) (*volumeOptions, *volumeIdentifier, error) {
func newVolumeOptionsFromMonitorList(
volID string,
options, secrets map[string]string) (*volumeOptions, *volumeIdentifier, error) {
var (
opts volumeOptions
vid volumeIdentifier
@ -412,7 +417,9 @@ func newVolumeOptionsFromMonitorList(volID string, options, secrets map[string]s
// newVolumeOptionsFromStaticVolume generates a new instance of volumeOptions and
// volumeIdentifier from the provided CSI volume context, if the provided context is
// detected to be a statically provisioned volume.
func newVolumeOptionsFromStaticVolume(volID string, options map[string]string) (*volumeOptions, *volumeIdentifier, error) {
func newVolumeOptionsFromStaticVolume(
volID string,
options map[string]string) (*volumeOptions, *volumeIdentifier, error) {
var (
opts volumeOptions
vid volumeIdentifier
@ -479,7 +486,10 @@ func newVolumeOptionsFromStaticVolume(volID string, options map[string]string) (
// newSnapshotOptionsFromID generates a new instance of volumeOptions and snapshotIdentifier
// from the provided CSI VolumeID.
func newSnapshotOptionsFromID(ctx context.Context, snapID string, cr *util.Credentials) (*volumeOptions, *snapshotInfo, *snapshotIdentifier, error) {
func newSnapshotOptionsFromID(
ctx context.Context,
snapID string,
cr *util.Credentials) (*volumeOptions, *snapshotInfo, *snapshotIdentifier, error) {
var (
vi util.CSIIdentifier
volOptions volumeOptions
@ -495,11 +505,17 @@ func newSnapshotOptionsFromID(ctx context.Context, snapID string, cr *util.Crede
volOptions.FscID = vi.LocationID
if volOptions.Monitors, err = util.Mons(util.CsiConfigFile, vi.ClusterID); err != nil {
return &volOptions, nil, &sid, fmt.Errorf("failed to fetch monitor list using clusterID (%s): %w", vi.ClusterID, err)
return &volOptions, nil, &sid, fmt.Errorf(
"failed to fetch monitor list using clusterID (%s): %w",
vi.ClusterID,
err)
}
if volOptions.SubvolumeGroup, err = util.CephFSSubvolumeGroup(util.CsiConfigFile, vi.ClusterID); err != nil {
return &volOptions, nil, &sid, fmt.Errorf("failed to fetch subvolumegroup list using clusterID (%s): %w", vi.ClusterID, err)
return &volOptions, nil, &sid, fmt.Errorf(
"failed to fetch subvolumegroup list using clusterID (%s): %w",
vi.ClusterID,
err)
}
err = volOptions.Connect(cr)