mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-14 02:43:36 +00:00
cleanup: do not pass an empty snapshot to genSnapFromSnapID()
Just like GenVolFromVolID() the genSnapFromSnapID() function can return a snapshot. There is no need to allocated an empty snapshot and pass that to the genSnapFromSnapID() function. Signed-off-by: Niels de Vos <ndevos@ibm.com>
This commit is contained in:
committed by
mergify[bot]
parent
063319f6e5
commit
18162c71bc
@ -638,7 +638,6 @@ func (cs *ControllerServer) createVolumeFromSnapshot(
|
||||
rbdVol *rbdVolume,
|
||||
snapshotID string,
|
||||
) error {
|
||||
rbdSnap := &rbdSnapshot{}
|
||||
if acquired := cs.SnapshotLocks.TryAcquire(snapshotID); !acquired {
|
||||
log.ErrorLog(ctx, util.SnapshotOperationAlreadyExistsFmt, snapshotID)
|
||||
|
||||
@ -646,7 +645,7 @@ func (cs *ControllerServer) createVolumeFromSnapshot(
|
||||
}
|
||||
defer cs.SnapshotLocks.Release(snapshotID)
|
||||
|
||||
err := genSnapFromSnapID(ctx, rbdSnap, snapshotID, cr, secrets)
|
||||
rbdSnap, err := genSnapFromSnapID(ctx, snapshotID, cr, secrets)
|
||||
if err != nil {
|
||||
if errors.Is(err, util.ErrPoolNotFound) {
|
||||
log.ErrorLog(ctx, "failed to get backend snapshot for %s: %v", snapshotID, err)
|
||||
@ -789,8 +788,8 @@ func checkContentSource(
|
||||
if snapshotID == "" {
|
||||
return nil, nil, status.Errorf(codes.NotFound, "volume Snapshot ID cannot be empty")
|
||||
}
|
||||
rbdSnap := &rbdSnapshot{}
|
||||
if err := genSnapFromSnapID(ctx, rbdSnap, snapshotID, cr, req.GetSecrets()); err != nil {
|
||||
rbdSnap, err := genSnapFromSnapID(ctx, snapshotID, cr, req.GetSecrets())
|
||||
if err != nil {
|
||||
log.ErrorLog(ctx, "failed to get backend snapshot for %s: %v", snapshotID, err)
|
||||
if !errors.Is(err, ErrSnapNotFound) {
|
||||
return nil, nil, status.Error(codes.Internal, err.Error())
|
||||
@ -1429,8 +1428,8 @@ func (cs *ControllerServer) DeleteSnapshot(
|
||||
}
|
||||
defer cs.OperationLocks.ReleaseDeleteLock(snapshotID)
|
||||
|
||||
rbdSnap := &rbdSnapshot{}
|
||||
if err = genSnapFromSnapID(ctx, rbdSnap, snapshotID, cr, req.GetSecrets()); err != nil {
|
||||
rbdSnap, err := genSnapFromSnapID(ctx, snapshotID, cr, req.GetSecrets())
|
||||
if err != nil {
|
||||
// if error is ErrPoolNotFound, the pool is already deleted we don't
|
||||
// need to worry about deleting snapshot or omap data, return success
|
||||
if errors.Is(err, util.ErrPoolNotFound) {
|
||||
|
Reference in New Issue
Block a user