From 1a1630d0c58be422db657df2234200379fec7432 Mon Sep 17 00:00:00 2001 From: Praveen M Date: Mon, 5 Aug 2024 17:55:12 +0530 Subject: [PATCH] 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 --- internal/cephfs/store/volumegroup.go | 2 +- internal/journal/volumegroupjournal.go | 6 ++++-- internal/rbd/manager.go | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/internal/cephfs/store/volumegroup.go b/internal/cephfs/store/volumegroup.go index 1140dcf6c..e2f69bb44 100644 --- a/internal/cephfs/store/volumegroup.go +++ b/internal/cephfs/store/volumegroup.go @@ -249,7 +249,7 @@ func ReserveVolumeGroup( defer j.Destroy() 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 { return nil, err } diff --git a/internal/journal/volumegroupjournal.go b/internal/journal/volumegroupjournal.go index 99ad8dafd..80012c887 100644 --- a/internal/journal/volumegroupjournal.go +++ b/internal/journal/volumegroupjournal.go @@ -54,6 +54,7 @@ type VolumeGroupJournal interface { ctx context.Context, journalPool, reqName, + groupUUID, namePrefix string) (string, string, error) // AddVolumesMapping adds a volumeMap map which contains volumeID's and its // 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: - journalPool: Pool where the CSI journal is stored - 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) Return values: @@ -320,7 +322,7 @@ Return values: - error: non-nil in case of any errors */ func (vgjc *volumeGroupJournalConnection) ReserveName(ctx context.Context, - journalPool, reqName, namePrefix string, + journalPool, reqName, groupUUID, namePrefix string, ) (string, string, error) { cj := vgjc.config @@ -335,7 +337,7 @@ func (vgjc *volumeGroupJournalConnection) ReserveName(ctx context.Context, journalPool, cj.namespace, cj.cephUUIDDirectoryPrefix, - "") + groupUUID) if err != nil { return "", "", err } diff --git a/internal/rbd/manager.go b/internal/rbd/manager.go index 8b0d6a064..441ca9f39 100644 --- a/internal/rbd/manager.go +++ b/internal/rbd/manager.go @@ -144,7 +144,7 @@ func (mgr *rbdManager) getGroupUUID( } else { 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 { 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) 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 { return nil, fmt.Errorf("failed to reserve volume group for name %q: %w", name, err) }