journal: pass groupUUID to be used for omap name reserve

This commit adds groupUUID param for `ReserveName` to be used for
OMAP name reserve instead of auto-generating.
This is useful for mirroring and metro-DR ensuring that mirrored
resources have consistent OMAP names across mirrored clusters.

Signed-off-by: Praveen M <m.praveen@ibm.com>
This commit is contained in:
Praveen M 2024-08-05 17:55:12 +05:30
parent cea8bf8110
commit 1a1630d0c5
3 changed files with 7 additions and 5 deletions

View File

@ -249,7 +249,7 @@ func ReserveVolumeGroup(
defer j.Destroy() defer j.Destroy()
groupUUID, vgsi.FsVolumeGroupSnapshotName, err = j.ReserveName( groupUUID, vgsi.FsVolumeGroupSnapshotName, err = j.ReserveName(
ctx, volOptions.MetadataPool, volOptions.RequestName, volOptions.NamePrefix) ctx, volOptions.MetadataPool, volOptions.RequestName, volOptions.ReservedID, volOptions.NamePrefix)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -54,6 +54,7 @@ type VolumeGroupJournal interface {
ctx context.Context, ctx context.Context,
journalPool, journalPool,
reqName, reqName,
groupUUID,
namePrefix string) (string, string, error) namePrefix string) (string, string, error)
// AddVolumesMapping adds a volumeMap map which contains volumeID's and its // AddVolumesMapping adds a volumeMap map which contains volumeID's and its
// corresponding values mapping which need to be added to the UUID // corresponding values mapping which need to be added to the UUID
@ -312,6 +313,7 @@ held, to prevent parallel operations from modifying the state of the omaps for t
Input arguments: Input arguments:
- journalPool: Pool where the CSI journal is stored - journalPool: Pool where the CSI journal is stored
- reqName: Name of the volumeGroupSnapshot request received - reqName: Name of the volumeGroupSnapshot request received
- groupUUID: UUID need to be reserved instead of auto-generating one (this is useful for RBD mirroring)
- namePrefix: Prefix to use when generating the volumeGroupName name (suffix is an auto-generated UUID) - namePrefix: Prefix to use when generating the volumeGroupName name (suffix is an auto-generated UUID)
Return values: Return values:
@ -320,7 +322,7 @@ Return values:
- error: non-nil in case of any errors - error: non-nil in case of any errors
*/ */
func (vgjc *volumeGroupJournalConnection) ReserveName(ctx context.Context, func (vgjc *volumeGroupJournalConnection) ReserveName(ctx context.Context,
journalPool, reqName, namePrefix string, journalPool, reqName, groupUUID, namePrefix string,
) (string, string, error) { ) (string, string, error) {
cj := vgjc.config cj := vgjc.config
@ -335,7 +337,7 @@ func (vgjc *volumeGroupJournalConnection) ReserveName(ctx context.Context,
journalPool, journalPool,
cj.namespace, cj.namespace,
cj.cephUUIDDirectoryPrefix, cj.cephUUIDDirectoryPrefix,
"") groupUUID)
if err != nil { if err != nil {
return "", "", err return "", "", err
} }

View File

@ -144,7 +144,7 @@ func (mgr *rbdManager) getGroupUUID(
} else { } else {
log.DebugLog(ctx, "the journal does not contain a reservation for group %q yet", name) log.DebugLog(ctx, "the journal does not contain a reservation for group %q yet", name)
uuid, _ /*vgsName*/, err = vgJournal.ReserveName(ctx, journalPool, name, prefix) uuid, _ /*vgsName*/, err = vgJournal.ReserveName(ctx, journalPool, name, vgsData.GroupUUID, prefix)
if err != nil { if err != nil {
return "", nothingToUndo, fmt.Errorf("failed to reserve a UUID for group %q: %w", name, err) return "", nothingToUndo, fmt.Errorf("failed to reserve a UUID for group %q: %w", name, err)
} }
@ -273,7 +273,7 @@ func (mgr *rbdManager) CreateVolumeGroup(ctx context.Context, name string) (type
log.DebugLog(ctx, "the journal does not contain a reservation for a volume group with name %q yet", name) log.DebugLog(ctx, "the journal does not contain a reservation for a volume group with name %q yet", name)
var vgName string var vgName string
uuid, vgName, err = vgJournal.ReserveName(ctx, journalPool, name, prefix) uuid, vgName, err = vgJournal.ReserveName(ctx, journalPool, name, vgData.GroupUUID, prefix)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to reserve volume group for name %q: %w", name, err) return nil, fmt.Errorf("failed to reserve volume group for name %q: %w", name, err)
} }