@@ -20,6 +20,7 @@ import (
2020 "context"
2121 "errors"
2222 "fmt"
23+ "reflect"
2324
2425 csi "github.com/container-storage-interface/spec/lib/go/csi"
2526 "google.golang.org/grpc"
@@ -56,14 +57,30 @@ func NewNodeServiceCapability(cap csi.NodeServiceCapability_RPC_Type) *csi.NodeS
5657 }
5758}
5859
60+ // Reflect magic below simply clears Secrets map from request.
61+ func clearSecrets (req interface {}) interface {} {
62+ v := reflect .ValueOf (& req ).Elem ()
63+ e := reflect .New (v .Elem ().Type ()).Elem ()
64+ e .Set (v .Elem ())
65+ f := reflect .Indirect (e ).FieldByName ("Secrets" )
66+ if f .IsValid () && f .CanSet () && f .Kind () == reflect .Map {
67+ f .Set (reflect .MakeMap (f .Type ()))
68+ v .Set (e )
69+ }
70+ return req
71+ }
72+
5973func logGRPC (ctx context.Context , req interface {}, info * grpc.UnaryServerInfo , handler grpc.UnaryHandler ) (interface {}, error ) {
6074 if info .FullMethod == ProbeCSIFullMethod {
6175 return handler (ctx , req )
6276 }
63- // Note that secrets are not included in any RPC message. In the past protosanitizer and other log
77+ // Note that secrets may be included in some RPC messages
78+ // (https://github.com/kubernetes-sigs/gcp-compute-persistent-disk-csi-driver/issues/1372),
79+ // but the driver ignores them. In the past protosanitizer and other log
6480 // stripping was shown to cause a significant increase of CPU usage (see
6581 // https://github.com/kubernetes-sigs/gcp-compute-persistent-disk-csi-driver/issues/356#issuecomment-550529004).
66- klog .V (4 ).Infof ("%s called with request: %s" , info .FullMethod , req )
82+ // That is why we use hand-crafted clearSecrets() below rather than protosanitizer.
83+ klog .V (4 ).Infof ("%s called with request: %s" , info .FullMethod , clearSecrets (req ))
6784 resp , err := handler (ctx , req )
6885 if err != nil {
6986 klog .Errorf ("%s returned with error: %v" , info .FullMethod , err .Error ())
0 commit comments