diff --git a/internal/rbd/controllerserver.go b/internal/rbd/controllerserver.go index 8d6107a54..3a41e9792 100644 --- a/internal/rbd/controllerserver.go +++ b/internal/rbd/controllerserver.go @@ -467,13 +467,13 @@ func (cs *ControllerServer) createBackingImage(ctx context.Context, cr *util.Cre switch { case rbdSnap != nil: - if err = cs.OperationLocks.GetRestoreLock(rbdSnap.SnapID); err != nil { + if err = cs.OperationLocks.GetRestoreLock(rbdSnap.VolID); err != nil { util.ErrorLog(ctx, err.Error()) return status.Error(codes.Aborted, err.Error()) } - defer cs.OperationLocks.ReleaseRestoreLock(rbdSnap.SnapID) + defer cs.OperationLocks.ReleaseRestoreLock(rbdSnap.VolID) - err = cs.createVolumeFromSnapshot(ctx, cr, rbdVol, rbdSnap.SnapID) + err = cs.createVolumeFromSnapshot(ctx, cr, rbdVol, rbdSnap.VolID) if err != nil { return err } @@ -813,7 +813,7 @@ func (cs *ControllerServer) CreateSnapshot(ctx context.Context, req *csi.CreateS return &csi.CreateSnapshotResponse{ Snapshot: &csi.Snapshot{ SizeBytes: rbdSnap.SizeBytes, - SnapshotId: rbdSnap.SnapID, + SnapshotId: rbdSnap.VolID, SourceVolumeId: rbdSnap.SourceVolumeID, CreationTime: rbdSnap.CreatedAt, ReadyToUse: false, @@ -831,7 +831,7 @@ func (cs *ControllerServer) CreateSnapshot(ctx context.Context, req *csi.CreateS return &csi.CreateSnapshotResponse{ Snapshot: &csi.Snapshot{ SizeBytes: rbdSnap.SizeBytes, - SnapshotId: rbdSnap.SnapID, + SnapshotId: rbdSnap.VolID, SourceVolumeId: rbdSnap.SourceVolumeID, CreationTime: rbdSnap.CreatedAt, ReadyToUse: true, diff --git a/internal/rbd/rbd_journal.go b/internal/rbd/rbd_journal.go index 734599aba..86f0d41c2 100644 --- a/internal/rbd/rbd_journal.go +++ b/internal/rbd/rbd_journal.go @@ -171,7 +171,7 @@ func checkSnapCloneExists(ctx context.Context, parentVol *rbdVolume, rbdSnap *rb rbdSnap.CreatedAt = vol.CreatedAt rbdSnap.SizeBytes = vol.VolSize // found a snapshot already available, process and return its information - rbdSnap.SnapID, err = util.GenerateVolID(ctx, rbdSnap.Monitors, cr, snapData.ImagePoolID, rbdSnap.Pool, + rbdSnap.VolID, err = util.GenerateVolID(ctx, rbdSnap.Monitors, cr, snapData.ImagePoolID, rbdSnap.Pool, rbdSnap.ClusterID, snapUUID, volIDVersion) if err != nil { return false, err @@ -208,7 +208,7 @@ func checkSnapCloneExists(ctx context.Context, parentVol *rbdVolume, rbdSnap *rb } util.DebugLog(ctx, "found existing image (%s) with name (%s) for request (%s)", - rbdSnap.SnapID, rbdSnap.RbdSnapName, rbdSnap.RequestName) + rbdSnap.VolID, rbdSnap.RbdSnapName, rbdSnap.RequestName) return true, nil } @@ -349,14 +349,14 @@ func reserveSnap(ctx context.Context, rbdSnap *rbdSnapshot, rbdVol *rbdVolume, c return err } - rbdSnap.SnapID, err = util.GenerateVolID(ctx, rbdSnap.Monitors, cr, imagePoolID, rbdSnap.Pool, + rbdSnap.VolID, err = util.GenerateVolID(ctx, rbdSnap.Monitors, cr, imagePoolID, rbdSnap.Pool, rbdSnap.ClusterID, rbdSnap.ReservedID, volIDVersion) if err != nil { return err } util.DebugLog(ctx, "generated Volume ID (%s) and image name (%s) for request name (%s)", - rbdSnap.SnapID, rbdSnap.RbdSnapName, rbdSnap.RequestName) + rbdSnap.VolID, rbdSnap.RbdSnapName, rbdSnap.RequestName) return nil } diff --git a/internal/rbd/rbd_util.go b/internal/rbd/rbd_util.go index 4cef4ccea..5540559a7 100644 --- a/internal/rbd/rbd_util.go +++ b/internal/rbd/rbd_util.go @@ -116,7 +116,7 @@ type rbdSnapshot struct { // SourceVolumeID is the volume ID of RbdImageName, that is exchanged with CSI drivers // RbdImageName is the name of the RBD image, that is this rbdSnapshot's source image // RbdSnapName is the name of the RBD snapshot backing this rbdSnapshot - // SnapID is the snapshot ID that is exchanged with CSI drivers, identifying this rbdSnapshot + // VolID is the snapshot ID that is exchanged with CSI drivers, identifying this rbdSnapshot // RequestName is the CSI generated snapshot name for the rbdSnapshot // JournalPool is the ceph pool in which the CSI snapshot Journal is stored // Pool is where the image snapshot journal and snapshot is stored, and could be the same as `JournalPool` @@ -126,7 +126,7 @@ type rbdSnapshot struct { ReservedID string NamePrefix string RbdSnapName string - SnapID string + VolID string ImageID string Monitors string JournalPool string @@ -696,11 +696,11 @@ func genSnapFromSnapID(ctx context.Context, rbdSnap *rbdSnapshot, snapshotID str ) options = make(map[string]string) - rbdSnap.SnapID = snapshotID + rbdSnap.VolID = snapshotID - err := vi.DecomposeCSIID(rbdSnap.SnapID) + err := vi.DecomposeCSIID(rbdSnap.VolID) if err != nil { - util.ErrorLog(ctx, "error decoding snapshot ID (%s) (%s)", err, rbdSnap.SnapID) + util.ErrorLog(ctx, "error decoding snapshot ID (%s) (%s)", err, rbdSnap.VolID) return err } diff --git a/internal/rbd/snapshot.go b/internal/rbd/snapshot.go index 6fb44d624..8d9cf0efa 100644 --- a/internal/rbd/snapshot.go +++ b/internal/rbd/snapshot.go @@ -82,7 +82,7 @@ func cleanUpSnapshot(ctx context.Context, parentVol *rbdVolume, rbdSnap *rbdSnap func generateVolFromSnap(rbdSnap *rbdSnapshot) *rbdVolume { vol := new(rbdVolume) vol.ClusterID = rbdSnap.ClusterID - vol.VolID = rbdSnap.SnapID + vol.VolID = rbdSnap.VolID vol.Monitors = rbdSnap.Monitors vol.Pool = rbdSnap.Pool vol.JournalPool = rbdSnap.JournalPool