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>
(cherry picked from commit 4e296bf)

# Conflicts:
#	internal/csi-common/utils.go
#	internal/csi-common/utils_test.go
  • Loading branch information
Madhu-1 authored and mergify[bot] committed Feb 13, 2024
1 parent 8e09311 commit 2046675
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
25 changes: 25 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 @@ -133,6 +134,30 @@ func getReqID(req interface{}) string {

case *csi.NodeExpandVolumeRequest:
reqID = r.VolumeId
<<<<<<< HEAD
=======

case *csi.CreateVolumeGroupSnapshotRequest:
reqID = r.Name
case *csi.DeleteVolumeGroupSnapshotRequest:
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
>>>>>>> 4e296bf65 (util: log repication RequestID)
}

return reqID
Expand Down
33 changes: 33 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 @@ -65,6 +66,38 @@ func TestGetReqID(t *testing.T) {
&csi.NodeExpandVolumeRequest{
VolumeId: fakeID,
},
<<<<<<< HEAD
=======

&csi.CreateVolumeGroupSnapshotRequest{
Name: fakeID,
},
&csi.DeleteVolumeGroupSnapshotRequest{
GroupSnapshotId: fakeID,
},
&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,
},
>>>>>>> 4e296bf65 (util: log repication RequestID)
}
for _, r := range req {
if got := getReqID(r); got != fakeID {
Expand Down

0 comments on commit 2046675

Please sign in to comment.