diff --git a/internal/cephfs/clone.go b/internal/cephfs/clone.go index bbe897d14..fdc831376 100644 --- a/internal/cephfs/clone.go +++ b/internal/cephfs/clone.go @@ -43,7 +43,7 @@ const ( 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 err := parentvolOpt.createSnapshot(ctx, snapshotID, volID) if err != nil { @@ -65,7 +65,7 @@ func createCloneFromSubvolume(ctx context.Context, volID, cloneID volumeID, volO } 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) } 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) } -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) err := parentVolOpt.cloneSnapshot(ctx, volumeID(sID.FsSubvolName), snapID, volumeID(vID.FsSubvolName), volOptions) if err != nil { @@ -176,7 +176,7 @@ func createCloneFromSnapshot(ctx context.Context, parentVolOpt, volOptions *volu defer func() { if err != nil { 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) } } diff --git a/internal/cephfs/controllerserver.go b/internal/cephfs/controllerserver.go index c917647be..032778683 100644 --- a/internal/cephfs/controllerserver.go +++ b/internal/cephfs/controllerserver.go @@ -55,8 +55,7 @@ func (cs *ControllerServer) createBackingVolume( vID, pvID *volumeIdentifier, - sID *snapshotIdentifier, - cr *util.Credentials) error { + sID *snapshotIdentifier) error { var err error if sID != nil { if err = cs.OperationLocks.GetRestoreLock(sID.SnapshotID); err != nil { @@ -65,7 +64,7 @@ func (cs *ControllerServer) createBackingVolume( } defer cs.OperationLocks.ReleaseRestoreLock(sID.SnapshotID) - err = createCloneFromSnapshot(ctx, parentVolOpt, volOptions, vID, sID, cr) + err = createCloneFromSnapshot(ctx, parentVolOpt, volOptions, vID, sID) if err != nil { util.ErrorLog(ctx, "failed to create clone from snapshot %s: %v", sID.FsSnapshotName, err) return err @@ -78,7 +77,7 @@ 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, cr) + 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 @@ -188,7 +187,7 @@ func (cs *ControllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol // explicitly err = volOptions.resizeVolume(ctx, volumeID(vID.FsSubvolName), volOptions.Size) if err != nil { - purgeErr := volOptions.purgeVolume(ctx, volumeID(vID.FsSubvolName), cr, false) + purgeErr := volOptions.purgeVolume(ctx, volumeID(vID.FsSubvolName), false) if purgeErr != nil { util.ErrorLog(ctx, "failed to delete volume %s: %v", requestName, purgeErr) // 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 - err = cs.createBackingVolume(ctx, volOptions, parentVol, vID, pvID, sID, cr) + err = cs.createBackingVolume(ctx, volOptions, parentVol, vID, pvID, sID) if err != nil { if isCloneRetryError(err) { 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() - 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) if errors.Is(err, ErrVolumeHasSnapshots) { return nil, status.Error(codes.FailedPrecondition, err.Error()) diff --git a/internal/cephfs/fsjournal.go b/internal/cephfs/fsjournal.go index d96d598ca..baf187f59 100644 --- a/internal/cephfs/fsjournal.go +++ b/internal/cephfs/fsjournal.go @@ -108,7 +108,7 @@ func checkVolExists(ctx context.Context, return nil, ErrClonePending } if cloneState == cephFSCloneFailed { - err = volOptions.purgeVolume(ctx, volumeID(vid.FsSubvolName), cr, true) + err = volOptions.purgeVolume(ctx, volumeID(vid.FsSubvolName), true) if err != nil { util.ErrorLog(ctx, "failed to delete volume %s: %v", vid.FsSubvolName, err) return nil, err diff --git a/internal/cephfs/volume.go b/internal/cephfs/volume.go index 4de25c725..0d4496107 100644 --- a/internal/cephfs/volume.go +++ b/internal/cephfs/volume.go @@ -209,7 +209,7 @@ func (vo *volumeOptions) resizeVolume(ctx context.Context, volID volumeID, bytes 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() if err != nil { util.ErrorLog(ctx, "could not get FSAdmin %s:", err)