mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-22 06:10:22 +00:00
cleanup: drop rbdVol.storeImageID() in favor of rbdVol.repairImageID()
Both `rbdVolume.repairImageID()` and `rbdVolume.storeImageID()` do the same thing. `repairImageID()` includes optional extra checking for an already set ImageID, which is not part of `storeImageID()`. Remove some unneeded `ImageID == ""` checking because `repairImageID()` does that, and remove the `storeImageID()` function. Signed-off-by: Niels de Vos <ndevos@ibm.com>
This commit is contained in:
parent
9b0383ce6c
commit
ddd41d358f
@ -790,7 +790,7 @@ func (cs *ControllerServer) createBackingImage(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
err = rbdVol.storeImageID(ctx, j)
|
err = rbdVol.repairImageID(ctx, j, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return status.Error(codes.Internal, err.Error())
|
return status.Error(codes.Internal, err.Error())
|
||||||
}
|
}
|
||||||
|
@ -541,7 +541,7 @@ func undoVolReservation(ctx context.Context, rbdVol *rbdVolume, cr *util.Credent
|
|||||||
// The volume handler won't remain same as its contains poolID,clusterID etc
|
// The volume handler won't remain same as its contains poolID,clusterID etc
|
||||||
// which are not same across clusters.
|
// which are not same across clusters.
|
||||||
//
|
//
|
||||||
//nolint:gocyclo,cyclop,nestif // TODO: reduce complexity
|
//nolint:gocyclo,cyclop // TODO: reduce complexity
|
||||||
func RegenerateJournal(
|
func RegenerateJournal(
|
||||||
volumeAttributes map[string]string,
|
volumeAttributes map[string]string,
|
||||||
claimName,
|
claimName,
|
||||||
@ -623,12 +623,12 @@ func RegenerateJournal(
|
|||||||
rbdVol.ImageID = imageData.ImageAttributes.ImageID
|
rbdVol.ImageID = imageData.ImageAttributes.ImageID
|
||||||
rbdVol.Owner = imageData.ImageAttributes.Owner
|
rbdVol.Owner = imageData.ImageAttributes.Owner
|
||||||
rbdVol.RbdImageName = imageData.ImageAttributes.ImageName
|
rbdVol.RbdImageName = imageData.ImageAttributes.ImageName
|
||||||
if rbdVol.ImageID == "" {
|
|
||||||
err = rbdVol.storeImageID(ctx, j)
|
err = rbdVol.repairImageID(ctx, j, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if rbdVol.Owner != owner {
|
if rbdVol.Owner != owner {
|
||||||
err = j.ResetVolumeOwner(ctx, rbdVol.JournalPool, rbdVol.ReservedID, owner)
|
err = j.ResetVolumeOwner(ctx, rbdVol.JournalPool, rbdVol.ReservedID, owner)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -675,30 +675,11 @@ func RegenerateJournal(
|
|||||||
|
|
||||||
log.DebugLog(ctx, "re-generated Volume ID (%s) and image name (%s) for request name (%s)",
|
log.DebugLog(ctx, "re-generated Volume ID (%s) and image name (%s) for request name (%s)",
|
||||||
rbdVol.VolID, rbdVol.RbdImageName, rbdVol.RequestName)
|
rbdVol.VolID, rbdVol.RbdImageName, rbdVol.RequestName)
|
||||||
if rbdVol.ImageID == "" {
|
|
||||||
err = rbdVol.storeImageID(ctx, j)
|
err = rbdVol.repairImageID(ctx, j, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return rbdVol.VolID, nil
|
return rbdVol.VolID, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// storeImageID retrieves the image ID and stores it in OMAP.
|
|
||||||
func (rv *rbdVolume) storeImageID(ctx context.Context, j *journal.Connection) error {
|
|
||||||
err := rv.getImageID()
|
|
||||||
if err != nil {
|
|
||||||
log.ErrorLog(ctx, "failed to get image id %s: %v", rv, err)
|
|
||||||
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
err = j.StoreImageID(ctx, rv.JournalPool, rv.ReservedID, rv.ImageID)
|
|
||||||
if err != nil {
|
|
||||||
log.ErrorLog(ctx, "failed to store volume id %s: %v", rv, err)
|
|
||||||
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
@ -1169,12 +1169,11 @@ func generateVolumeFromVolumeID(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if rbdVol.ImageID == "" {
|
err = rbdVol.repairImageID(ctx, j, false)
|
||||||
err = rbdVol.storeImageID(ctx, j)
|
if err != nil {
|
||||||
if err != nil {
|
return rbdVol, err
|
||||||
return rbdVol, err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
err = rbdVol.getImageInfo()
|
err = rbdVol.getImageInfo()
|
||||||
|
|
||||||
return rbdVol, err
|
return rbdVol, err
|
||||||
|
Loading…
Reference in New Issue
Block a user