Skip to content

Commit

Permalink
util: log repication RequestID
Browse files Browse the repository at this point in the history
currently we are not logging the RequestID
for the replication RPC calls. This PR
adds the replication case to the getReqID
function.

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
  • Loading branch information
Madhu-1 authored and mergify[bot] committed Feb 13, 2024
1 parent 492e436 commit 4e296bf
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
15 changes: 15 additions & 0 deletions internal/csi-common/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"github.com/ceph/ceph-csi/internal/util/log"

"github.com/container-storage-interface/spec/lib/go/csi"
"github.com/csi-addons/spec/lib/go/replication"
grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware"
"github.com/kubernetes-csi/csi-lib-utils/protosanitizer"
"google.golang.org/grpc"
Expand Down Expand Up @@ -152,6 +153,20 @@ func getReqID(req interface{}) string {
reqID = r.GroupSnapshotId
case *csi.GetVolumeGroupSnapshotRequest:
reqID = r.GroupSnapshotId

// Replication
case *replication.EnableVolumeReplicationRequest:
reqID = r.VolumeId
case *replication.DisableVolumeReplicationRequest:
reqID = r.VolumeId
case *replication.PromoteVolumeRequest:
reqID = r.VolumeId
case *replication.DemoteVolumeRequest:
reqID = r.VolumeId
case *replication.ResyncVolumeRequest:
reqID = r.VolumeId
case *replication.GetVolumeReplicationInfoRequest:
reqID = r.VolumeId
}

return reqID
Expand Down
20 changes: 20 additions & 0 deletions internal/csi-common/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"testing"

"github.com/container-storage-interface/spec/lib/go/csi"
"github.com/csi-addons/spec/lib/go/replication"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
mount "k8s.io/mount-utils"
Expand Down Expand Up @@ -75,6 +76,25 @@ func TestGetReqID(t *testing.T) {
&csi.GetVolumeGroupSnapshotRequest{
GroupSnapshotId: fakeID,
},

&replication.EnableVolumeReplicationRequest{
VolumeId: fakeID,
},
&replication.DisableVolumeReplicationRequest{
VolumeId: fakeID,
},
&replication.PromoteVolumeRequest{
VolumeId: fakeID,
},
&replication.DemoteVolumeRequest{
VolumeId: fakeID,
},
&replication.ResyncVolumeRequest{
VolumeId: fakeID,
},
&replication.GetVolumeReplicationInfoRequest{
VolumeId: fakeID,
},
}
for _, r := range req {
if got := getReqID(r); got != fakeID {
Expand Down

0 comments on commit 4e296bf

Please sign in to comment.