@@ -20,6 +20,7 @@ import (
20
20
"context"
21
21
"errors"
22
22
"fmt"
23
+ "reflect"
23
24
24
25
csi "github.com/container-storage-interface/spec/lib/go/csi"
25
26
"google.golang.org/grpc"
@@ -56,14 +57,30 @@ func NewNodeServiceCapability(cap csi.NodeServiceCapability_RPC_Type) *csi.NodeS
56
57
}
57
58
}
58
59
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
+
59
73
func logGRPC (ctx context.Context , req interface {}, info * grpc.UnaryServerInfo , handler grpc.UnaryHandler ) (interface {}, error ) {
60
74
if info .FullMethod == ProbeCSIFullMethod {
61
75
return handler (ctx , req )
62
76
}
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
64
80
// stripping was shown to cause a significant increase of CPU usage (see
65
81
// 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 ))
67
84
resp , err := handler (ctx , req )
68
85
if err != nil {
69
86
klog .Errorf ("%s returned with error: %v" , info .FullMethod , err .Error ())
0 commit comments