rbd: use 'rv' as name of the rbdVolume (golint)

golint has a pretty struct stylechek, it down not allow different
variable names for methods on an object:

    pkg/rbd/rbd_util.go:970:1: receiver name rbdVol should be consistent with previous receiver name rv for rbdVolume (golint)
    func (rbdVol *rbdVolume) ensureEncryptionMetadataSet(ctx context.Context) error {
    ^
    pkg/rbd/rbd_journal.go:166:26: ST1016: methods on the same type should have the same receiver name (seen 2x "rbdVol", 3x "rv") (stylecheck)
    func (rbdVol *rbdVolume) Exists(ctx context.Context) (bool, error) {
                             ^

Rename the 'rbdVol' variable to 'rv' to make it consistent.

Signed-off-by: Niels de Vos <ndevos@redhat.com>
This commit is contained in:
Niels de Vos 2020-04-06 11:16:23 +02:00 committed by mergify[bot]
parent f814bd72e5
commit c89c68e9ea

View File

@ -163,19 +163,19 @@ volume names as requested by the CSI drivers. Hence, these need to be invoked on
respective CSI snapshot or volume name based locks are held, as otherwise racy access to these respective CSI snapshot or volume name based locks are held, as otherwise racy access to these
omaps may end up leaving the omaps in an inconsistent state. omaps may end up leaving the omaps in an inconsistent state.
*/ */
func (rbdVol *rbdVolume) Exists(ctx context.Context) (bool, error) { func (rv *rbdVolume) Exists(ctx context.Context) (bool, error) {
err := validateRbdVol(rbdVol) err := validateRbdVol(rv)
if err != nil { if err != nil {
return false, err return false, err
} }
kmsID := "" kmsID := ""
if rbdVol.Encrypted { if rv.Encrypted {
kmsID = rbdVol.KMS.GetID() kmsID = rv.KMS.GetID()
} }
imageData, err := volJournal.CheckReservation(ctx, rbdVol.Monitors, rbdVol.conn.Creds, rbdVol.JournalPool, imageData, err := volJournal.CheckReservation(ctx, rv.Monitors, rv.conn.Creds, rv.JournalPool,
rbdVol.RequestName, rbdVol.NamePrefix, "", kmsID) rv.RequestName, rv.NamePrefix, "", kmsID)
if err != nil { if err != nil {
return false, err return false, err
} }
@ -184,51 +184,51 @@ func (rbdVol *rbdVolume) Exists(ctx context.Context) (bool, error) {
} }
imageUUID := imageData.ImageUUID imageUUID := imageData.ImageUUID
rbdVol.RbdImageName = imageData.ImageAttributes.ImageName rv.RbdImageName = imageData.ImageAttributes.ImageName
// check if topology constraints match what is found // check if topology constraints match what is found
rbdVol.Topology, err = util.MatchTopologyForPool(rbdVol.TopologyPools, rv.Topology, err = util.MatchTopologyForPool(rv.TopologyPools, rv.TopologyRequirement,
rbdVol.TopologyRequirement, imageData.ImagePool) imageData.ImagePool)
if err != nil { if err != nil {
// TODO check if need any undo operation here, or ErrVolNameConflict // TODO check if need any undo operation here, or ErrVolNameConflict
return false, err return false, err
} }
// update Pool, if it was topology constrained // update Pool, if it was topology constrained
if rbdVol.Topology != nil { if rv.Topology != nil {
rbdVol.Pool = imageData.ImagePool rv.Pool = imageData.ImagePool
} }
// NOTE: Return volsize should be on-disk volsize, not request vol size, so // NOTE: Return volsize should be on-disk volsize, not request vol size, so
// save it for size checks before fetching image data // save it for size checks before fetching image data
requestSize := rbdVol.VolSize requestSize := rv.VolSize
// Fetch on-disk image attributes and compare against request // Fetch on-disk image attributes and compare against request
err = updateVolWithImageInfo(ctx, rbdVol, rbdVol.conn.Creds) err = updateVolWithImageInfo(ctx, rv, rv.conn.Creds)
if err != nil { if err != nil {
if _, ok := err.(ErrImageNotFound); ok { if _, ok := err.(ErrImageNotFound); ok {
err = volJournal.UndoReservation(ctx, rbdVol.Monitors, rbdVol.conn.Creds, rbdVol.JournalPool, rbdVol.Pool, err = volJournal.UndoReservation(ctx, rv.Monitors, rv.conn.Creds, rv.JournalPool, rv.Pool,
rbdVol.RbdImageName, rbdVol.RequestName) rv.RbdImageName, rv.RequestName)
return false, err return false, err
} }
return false, err return false, err
} }
// size checks // size checks
if rbdVol.VolSize < requestSize { if rv.VolSize < requestSize {
err = fmt.Errorf("image with the same name (%s) but with different size already exists", err = fmt.Errorf("image with the same name (%s) but with different size already exists",
rbdVol.RbdImageName) rv.RbdImageName)
return false, ErrVolNameConflict{rbdVol.RbdImageName, err} return false, ErrVolNameConflict{rv.RbdImageName, err}
} }
// TODO: We should also ensure image features and format is the same // TODO: We should also ensure image features and format is the same
// found a volume already available, process and return it! // found a volume already available, process and return it!
rbdVol.VolID, err = util.GenerateVolID(ctx, rbdVol.Monitors, rbdVol.conn.Creds, imageData.ImagePoolID, rbdVol.Pool, rv.VolID, err = util.GenerateVolID(ctx, rv.Monitors, rv.conn.Creds, imageData.ImagePoolID, rv.Pool,
rbdVol.ClusterID, imageUUID, volIDVersion) rv.ClusterID, imageUUID, volIDVersion)
if err != nil { if err != nil {
return false, err return false, err
} }
klog.V(4).Infof(util.Log(ctx, "found existing volume (%s) with image name (%s) for request (%s)"), klog.V(4).Infof(util.Log(ctx, "found existing volume (%s) with image name (%s) for request (%s)"),
rbdVol.VolID, rbdVol.RbdImageName, rbdVol.RequestName) rv.VolID, rv.RbdImageName, rv.RequestName)
return true, nil return true, nil
} }