cephfs: remove unused cr Credentials

removed unused cr variable.

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
Madhu Rajanna 2020-12-09 12:25:37 +05:30 committed by mergify[bot]
parent 9a96370942
commit 0d9fcbc21b
4 changed files with 12 additions and 13 deletions

View File

@ -43,7 +43,7 @@ const (
snapshotIsProtected = "yes" snapshotIsProtected = "yes"
) )
func createCloneFromSubvolume(ctx context.Context, volID, cloneID volumeID, volOpt, parentvolOpt *volumeOptions, cr *util.Credentials) error { func createCloneFromSubvolume(ctx context.Context, volID, cloneID volumeID, volOpt, parentvolOpt *volumeOptions) error {
snapshotID := cloneID snapshotID := cloneID
err := parentvolOpt.createSnapshot(ctx, snapshotID, volID) err := parentvolOpt.createSnapshot(ctx, snapshotID, volID)
if err != nil { if err != nil {
@ -65,7 +65,7 @@ func createCloneFromSubvolume(ctx context.Context, volID, cloneID volumeID, volO
} }
if cloneErr != nil { if cloneErr != nil {
if err = volOpt.purgeVolume(ctx, cloneID, cr, true); err != nil { if err = volOpt.purgeVolume(ctx, cloneID, true); err != nil {
util.ErrorLog(ctx, "failed to delete volume %s: %v", cloneID, err) util.ErrorLog(ctx, "failed to delete volume %s: %v", cloneID, err)
} }
if err = parentvolOpt.unprotectSnapshot(ctx, snapshotID, volID); err != nil { if err = parentvolOpt.unprotectSnapshot(ctx, snapshotID, volID); err != nil {
@ -167,7 +167,7 @@ func isCloneRetryError(err error) bool {
return errors.Is(err, ErrCloneInProgress) || errors.Is(err, ErrClonePending) return errors.Is(err, ErrCloneInProgress) || errors.Is(err, ErrClonePending)
} }
func createCloneFromSnapshot(ctx context.Context, parentVolOpt, volOptions *volumeOptions, vID *volumeIdentifier, sID *snapshotIdentifier, cr *util.Credentials) error { func createCloneFromSnapshot(ctx context.Context, parentVolOpt, volOptions *volumeOptions, vID *volumeIdentifier, sID *snapshotIdentifier) error {
snapID := volumeID(sID.FsSnapshotName) snapID := volumeID(sID.FsSnapshotName)
err := parentVolOpt.cloneSnapshot(ctx, volumeID(sID.FsSubvolName), snapID, volumeID(vID.FsSubvolName), volOptions) err := parentVolOpt.cloneSnapshot(ctx, volumeID(sID.FsSubvolName), snapID, volumeID(vID.FsSubvolName), volOptions)
if err != nil { if err != nil {
@ -176,7 +176,7 @@ func createCloneFromSnapshot(ctx context.Context, parentVolOpt, volOptions *volu
defer func() { defer func() {
if err != nil { if err != nil {
if !isCloneRetryError(err) { if !isCloneRetryError(err) {
if dErr := volOptions.purgeVolume(ctx, volumeID(vID.FsSubvolName), cr, true); dErr != nil { if dErr := volOptions.purgeVolume(ctx, volumeID(vID.FsSubvolName), true); dErr != nil {
util.ErrorLog(ctx, "failed to delete volume %s: %v", vID.FsSubvolName, dErr) util.ErrorLog(ctx, "failed to delete volume %s: %v", vID.FsSubvolName, dErr)
} }
} }

View File

@ -55,8 +55,7 @@ func (cs *ControllerServer) createBackingVolume(
vID, vID,
pvID *volumeIdentifier, pvID *volumeIdentifier,
sID *snapshotIdentifier, sID *snapshotIdentifier) error {
cr *util.Credentials) error {
var err error var err error
if sID != nil { if sID != nil {
if err = cs.OperationLocks.GetRestoreLock(sID.SnapshotID); err != nil { if err = cs.OperationLocks.GetRestoreLock(sID.SnapshotID); err != nil {
@ -65,7 +64,7 @@ func (cs *ControllerServer) createBackingVolume(
} }
defer cs.OperationLocks.ReleaseRestoreLock(sID.SnapshotID) defer cs.OperationLocks.ReleaseRestoreLock(sID.SnapshotID)
err = createCloneFromSnapshot(ctx, parentVolOpt, volOptions, vID, sID, cr) err = createCloneFromSnapshot(ctx, parentVolOpt, volOptions, vID, sID)
if err != nil { if err != nil {
util.ErrorLog(ctx, "failed to create clone from snapshot %s: %v", sID.FsSnapshotName, err) util.ErrorLog(ctx, "failed to create clone from snapshot %s: %v", sID.FsSnapshotName, err)
return err return err
@ -78,7 +77,7 @@ func (cs *ControllerServer) createBackingVolume(
return status.Error(codes.Aborted, err.Error()) return status.Error(codes.Aborted, err.Error())
} }
defer cs.OperationLocks.ReleaseCloneLock(pvID.VolumeID) defer cs.OperationLocks.ReleaseCloneLock(pvID.VolumeID)
err = createCloneFromSubvolume(ctx, volumeID(pvID.FsSubvolName), volumeID(vID.FsSubvolName), volOptions, parentVolOpt, cr) err = createCloneFromSubvolume(ctx, volumeID(pvID.FsSubvolName), volumeID(vID.FsSubvolName), volOptions, parentVolOpt)
if err != nil { if err != nil {
util.ErrorLog(ctx, "failed to create clone from subvolume %s: %v", volumeID(pvID.FsSubvolName), err) util.ErrorLog(ctx, "failed to create clone from subvolume %s: %v", volumeID(pvID.FsSubvolName), err)
return err return err
@ -188,7 +187,7 @@ func (cs *ControllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol
// explicitly // explicitly
err = volOptions.resizeVolume(ctx, volumeID(vID.FsSubvolName), volOptions.Size) err = volOptions.resizeVolume(ctx, volumeID(vID.FsSubvolName), volOptions.Size)
if err != nil { if err != nil {
purgeErr := volOptions.purgeVolume(ctx, volumeID(vID.FsSubvolName), cr, false) purgeErr := volOptions.purgeVolume(ctx, volumeID(vID.FsSubvolName), false)
if purgeErr != nil { if purgeErr != nil {
util.ErrorLog(ctx, "failed to delete volume %s: %v", requestName, purgeErr) util.ErrorLog(ctx, "failed to delete volume %s: %v", requestName, purgeErr)
// All errors other than ErrVolumeNotFound should return an error back to the caller // All errors other than ErrVolumeNotFound should return an error back to the caller
@ -244,7 +243,7 @@ func (cs *ControllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol
}() }()
// Create a volume // Create a volume
err = cs.createBackingVolume(ctx, volOptions, parentVol, vID, pvID, sID, cr) err = cs.createBackingVolume(ctx, volOptions, parentVol, vID, pvID, sID)
if err != nil { if err != nil {
if isCloneRetryError(err) { if isCloneRetryError(err) {
return nil, status.Error(codes.Aborted, err.Error()) return nil, status.Error(codes.Aborted, err.Error())
@ -349,7 +348,7 @@ func (cs *ControllerServer) DeleteVolume(ctx context.Context, req *csi.DeleteVol
} }
defer cr.DeleteCredentials() defer cr.DeleteCredentials()
if err = volOptions.purgeVolume(ctx, volumeID(vID.FsSubvolName), cr, false); err != nil { if err = volOptions.purgeVolume(ctx, volumeID(vID.FsSubvolName), false); err != nil {
util.ErrorLog(ctx, "failed to delete volume %s: %v", volID, err) util.ErrorLog(ctx, "failed to delete volume %s: %v", volID, err)
if errors.Is(err, ErrVolumeHasSnapshots) { if errors.Is(err, ErrVolumeHasSnapshots) {
return nil, status.Error(codes.FailedPrecondition, err.Error()) return nil, status.Error(codes.FailedPrecondition, err.Error())

View File

@ -108,7 +108,7 @@ func checkVolExists(ctx context.Context,
return nil, ErrClonePending return nil, ErrClonePending
} }
if cloneState == cephFSCloneFailed { if cloneState == cephFSCloneFailed {
err = volOptions.purgeVolume(ctx, volumeID(vid.FsSubvolName), cr, true) err = volOptions.purgeVolume(ctx, volumeID(vid.FsSubvolName), true)
if err != nil { if err != nil {
util.ErrorLog(ctx, "failed to delete volume %s: %v", vid.FsSubvolName, err) util.ErrorLog(ctx, "failed to delete volume %s: %v", vid.FsSubvolName, err)
return nil, err return nil, err

View File

@ -209,7 +209,7 @@ func (vo *volumeOptions) resizeVolume(ctx context.Context, volID volumeID, bytes
return createVolume(ctx, vo, volID, bytesQuota) return createVolume(ctx, vo, volID, bytesQuota)
} }
func (vo *volumeOptions) purgeVolume(ctx context.Context, volID volumeID, cr *util.Credentials, force bool) error { func (vo *volumeOptions) purgeVolume(ctx context.Context, volID volumeID, force bool) error {
fsa, err := vo.conn.GetFSAdmin() fsa, err := vo.conn.GetFSAdmin()
if err != nil { if err != nil {
util.ErrorLog(ctx, "could not get FSAdmin %s:", err) util.ErrorLog(ctx, "could not get FSAdmin %s:", err)