mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-09 16:00:22 +00:00
rbd: add support to get volumegroupID
updated GetIDFromReplication to return volumeGroupID if its present. Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
parent
f7c78ae4fe
commit
3a8981a735
@ -128,6 +128,11 @@ func GetIDFromReplication(req interface{}) string {
|
||||
if src != nil && src.GetVolume() != nil {
|
||||
reqID = src.GetVolume().GetVolumeId()
|
||||
}
|
||||
if reqID == "" {
|
||||
if src != nil && src.GetVolumegroup() != nil {
|
||||
reqID = src.GetVolumegroup().GetVolumeGroupId()
|
||||
}
|
||||
}
|
||||
if reqID == "" {
|
||||
reqID = r.GetVolumeId() //nolint:nolintlint,staticcheck // req.VolumeId is deprecated
|
||||
}
|
||||
|
@ -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 {
|
||||
@ -161,6 +216,11 @@ func TestGetReqID(t *testing.T) {
|
||||
if got := getReqID(nil); got != "" {
|
||||
t.Errorf("getReqID() = %v, want empty string", got)
|
||||
}
|
||||
|
||||
// test when both volume and group id not set
|
||||
if got := getReqID(&replication.EnableVolumeReplicationRequest{}); got != "" {
|
||||
t.Errorf("getReqID() = %v, want empty string", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFilesystemNodeGetVolumeStats(t *testing.T) {
|
||||
|
Loading…
Reference in New Issue
Block a user