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 {