From d2a3649cca3cc48a9402716c86ecc3560eceb9ed Mon Sep 17 00:00:00 2001 From: Madhu Rajanna Date: Tue, 30 Jul 2024 16:54:39 +0200 Subject: [PATCH] rbd: add support to get volumegroupID updated GetIDFromReplication to return volumeGroupID if its present. Signed-off-by: Madhu Rajanna --- internal/csi-common/utils.go | 3 ++ internal/csi-common/utils_test.go | 55 +++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/internal/csi-common/utils.go b/internal/csi-common/utils.go index 3f2dadd126a8..5ea64c679357 100644 --- a/internal/csi-common/utils.go +++ b/internal/csi-common/utils.go @@ -131,6 +131,9 @@ func GetIDFromReplication(req interface{}) string { if reqID == "" { reqID = r.GetVolumeId() //nolint:nolintlint,staticcheck // req.VolumeId is deprecated } + if reqID == "" { + reqID = src.GetVolumegroup().GetVolumeGroupId() + } return reqID } diff --git a/internal/csi-common/utils_test.go b/internal/csi-common/utils_test.go index a3c230d0d1a3..808a1dbd5ca3 100644 --- a/internal/csi-common/utils_test.go +++ b/internal/csi-common/utils_test.go @@ -150,6 +150,61 @@ func TestGetReqID(t *testing.T) { }, }, }, + // volumeGroupId is set in ReplicationSource + &replication.EnableVolumeReplicationRequest{ + ReplicationSource: &replication.ReplicationSource{ + Type: &replication.ReplicationSource_Volumegroup{ + Volumegroup: &replication.ReplicationSource_VolumeGroupSource{ + VolumeGroupId: fakeID, + }, + }, + }, + }, + &replication.DisableVolumeReplicationRequest{ + ReplicationSource: &replication.ReplicationSource{ + Type: &replication.ReplicationSource_Volumegroup{ + Volumegroup: &replication.ReplicationSource_VolumeGroupSource{ + VolumeGroupId: fakeID, + }, + }, + }, + }, + &replication.PromoteVolumeRequest{ + ReplicationSource: &replication.ReplicationSource{ + Type: &replication.ReplicationSource_Volumegroup{ + Volumegroup: &replication.ReplicationSource_VolumeGroupSource{ + VolumeGroupId: fakeID, + }, + }, + }, + }, + &replication.DemoteVolumeRequest{ + ReplicationSource: &replication.ReplicationSource{ + Type: &replication.ReplicationSource_Volumegroup{ + Volumegroup: &replication.ReplicationSource_VolumeGroupSource{ + VolumeGroupId: fakeID, + }, + }, + }, + }, + &replication.ResyncVolumeRequest{ + ReplicationSource: &replication.ReplicationSource{ + Type: &replication.ReplicationSource_Volumegroup{ + Volumegroup: &replication.ReplicationSource_VolumeGroupSource{ + VolumeGroupId: fakeID, + }, + }, + }, + }, + &replication.GetVolumeReplicationInfoRequest{ + ReplicationSource: &replication.ReplicationSource{ + Type: &replication.ReplicationSource_Volumegroup{ + Volumegroup: &replication.ReplicationSource_VolumeGroupSource{ + VolumeGroupId: fakeID, + }, + }, + }, + }, } for _, r := range req { if got := getReqID(r); got != fakeID {