cleanup: replace parentName to snapParentName in checkReservation

at present, eventhough the checkReservation works for both volume
and snapshot, the arg parentName make sense only for snapshot cases
renaming that arg to more approprite

Signed-off-by: Humble Chirammal <hchiramm@redhat.com>
This commit is contained in:
Humble Chirammal 2021-09-08 10:42:30 +05:30 committed by mergify[bot]
parent 1fee3ec460
commit 4be53a27d3

View File

@ -264,7 +264,7 @@ CheckReservation checks if given request name contains a valid reservation
- If there is a valid reservation, then the corresponding ImageData for the volume/snapshot is returned - If there is a valid reservation, then the corresponding ImageData for the volume/snapshot is returned
- If there is a reservation that is stale (or not fully cleaned up), it is garbage collected using - If there is a reservation that is stale (or not fully cleaned up), it is garbage collected using
the UndoReservation call, as appropriate the UndoReservation call, as appropriate
- If a snapshot is being checked, then its source is matched to the parentName that is provided - If a snapshot is being checked, then its source is matched to the snapParentName that is provided
NOTE: As the function manipulates omaps, it should be called with a lock against the request name NOTE: As the function manipulates omaps, it should be called with a lock against the request name
held, to prevent parallel operations from modifying the state of the omaps for this request name. held, to prevent parallel operations from modifying the state of the omaps for this request name.
@ -275,7 +275,7 @@ Return values:
- error: non-nil in case of any errors - error: non-nil in case of any errors
*/ */
func (conn *Connection) CheckReservation(ctx context.Context, func (conn *Connection) CheckReservation(ctx context.Context,
journalPool, reqName, namePrefix, parentName, kmsConfig string) (*ImageData, error) { journalPool, reqName, namePrefix, snapParentName, kmsConfig string) (*ImageData, error) {
var ( var (
snapSource bool snapSource bool
objUUID string objUUID string
@ -284,7 +284,7 @@ func (conn *Connection) CheckReservation(ctx context.Context,
cj = conn.config cj = conn.config
) )
if parentName != "" { if snapParentName != "" {
if cj.cephSnapSourceKey == "" { if cj.cephSnapSourceKey == "" {
err := errors.New("invalid request, cephSnapSourceKey is nil") err := errors.New("invalid request, cephSnapSourceKey is nil")
@ -378,12 +378,12 @@ func (conn *Connection) CheckReservation(ctx context.Context,
if snapSource { if snapSource {
// check if source UUID key points back to the parent volume passed in // check if source UUID key points back to the parent volume passed in
if savedImageAttributes.SourceName != parentName { if savedImageAttributes.SourceName != snapParentName {
// NOTE: This can happen if there is a snapname conflict, and we already have a snapshot // NOTE: This can happen if there is a snapname conflict, and we already have a snapshot
// with the same name pointing to a different UUID as the source // with the same name pointing to a different UUID as the source
err = fmt.Errorf("%w: snapname points to different volume, request name (%s)"+ err = fmt.Errorf("%w: snapname points to different volume, request name (%s)"+
" source name (%s) saved source name (%s)", util.ErrSnapNameConflict, " source name (%s) : saved source name (%s)", util.ErrSnapNameConflict,
reqName, parentName, savedImageAttributes.SourceName) reqName, snapParentName, savedImageAttributes.SourceName)
return nil, err return nil, err
} }