From 2a52096ad0040704c20fb8297d3f48e2f61862b0 Mon Sep 17 00:00:00 2001 From: Madhu Rajanna Date: Tue, 13 Feb 2024 08:00:21 +0100 Subject: [PATCH] util: log repication RequestID 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 (cherry picked from commit 4e296bf65e37e1141481f29c85371683c07c48f6) Signed-off-by: Niels de Vos --- internal/csi-common/utils.go | 15 +++++++++++++++ internal/csi-common/utils_test.go | 20 ++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/internal/csi-common/utils.go b/internal/csi-common/utils.go index 080f9df93..052416a1c 100644 --- a/internal/csi-common/utils.go +++ b/internal/csi-common/utils.go @@ -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" @@ -133,6 +134,20 @@ func getReqID(req interface{}) string { case *csi.NodeExpandVolumeRequest: reqID = r.VolumeId + + // 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 diff --git a/internal/csi-common/utils_test.go b/internal/csi-common/utils_test.go index e5687986a..677dab07c 100644 --- a/internal/csi-common/utils_test.go +++ b/internal/csi-common/utils_test.go @@ -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" @@ -65,6 +66,25 @@ func TestGetReqID(t *testing.T) { &csi.NodeExpandVolumeRequest{ VolumeId: 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 {