Skip to content

Commit 09f91db

Browse files
committed
rbd: add support to get volumegroupID
updated GetIDFromReplication to return volumeGroupID if its present. Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
1 parent fdc1bd9 commit 09f91db

2 files changed

Lines changed: 58 additions & 0 deletions

File tree

internal/csi-common/utils.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ func GetIDFromReplication(req interface{}) string {
131131
if reqID == "" {
132132
reqID = r.GetVolumeId() //nolint:nolintlint,staticcheck // req.VolumeId is deprecated
133133
}
134+
if reqID == "" {
135+
reqID = src.GetVolumegroup().GetVolumeGroupId()
136+
}
134137

135138
return reqID
136139
}

internal/csi-common/utils_test.go

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,61 @@ func TestGetReqID(t *testing.T) {
150150
},
151151
},
152152
},
153+
// volumeGroupId is set in ReplicationSource
154+
&replication.EnableVolumeReplicationRequest{
155+
ReplicationSource: &replication.ReplicationSource{
156+
Type: &replication.ReplicationSource_Volumegroup{
157+
Volumegroup: &replication.ReplicationSource_VolumeGroupSource{
158+
VolumeGroupId: fakeID,
159+
},
160+
},
161+
},
162+
},
163+
&replication.DisableVolumeReplicationRequest{
164+
ReplicationSource: &replication.ReplicationSource{
165+
Type: &replication.ReplicationSource_Volumegroup{
166+
Volumegroup: &replication.ReplicationSource_VolumeGroupSource{
167+
VolumeGroupId: fakeID,
168+
},
169+
},
170+
},
171+
},
172+
&replication.PromoteVolumeRequest{
173+
ReplicationSource: &replication.ReplicationSource{
174+
Type: &replication.ReplicationSource_Volumegroup{
175+
Volumegroup: &replication.ReplicationSource_VolumeGroupSource{
176+
VolumeGroupId: fakeID,
177+
},
178+
},
179+
},
180+
},
181+
&replication.DemoteVolumeRequest{
182+
ReplicationSource: &replication.ReplicationSource{
183+
Type: &replication.ReplicationSource_Volumegroup{
184+
Volumegroup: &replication.ReplicationSource_VolumeGroupSource{
185+
VolumeGroupId: fakeID,
186+
},
187+
},
188+
},
189+
},
190+
&replication.ResyncVolumeRequest{
191+
ReplicationSource: &replication.ReplicationSource{
192+
Type: &replication.ReplicationSource_Volumegroup{
193+
Volumegroup: &replication.ReplicationSource_VolumeGroupSource{
194+
VolumeGroupId: fakeID,
195+
},
196+
},
197+
},
198+
},
199+
&replication.GetVolumeReplicationInfoRequest{
200+
ReplicationSource: &replication.ReplicationSource{
201+
Type: &replication.ReplicationSource_Volumegroup{
202+
Volumegroup: &replication.ReplicationSource_VolumeGroupSource{
203+
VolumeGroupId: fakeID,
204+
},
205+
},
206+
},
207+
},
153208
}
154209
for _, r := range req {
155210
if got := getReqID(r); got != fakeID {

0 commit comments

Comments
 (0)