Skip to content

Commit

Permalink
rbd: add support to get volumegroupID
Browse files Browse the repository at this point in the history
updated GetIDFromReplication to return
volumeGroupID if its present.

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
  • Loading branch information
Madhu-1 committed Jul 30, 2024
1 parent fdc1bd9 commit 09f91db
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
3 changes: 3 additions & 0 deletions internal/csi-common/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
55 changes: 55 additions & 0 deletions internal/csi-common/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 09f91db

Please sign in to comment.