@@ -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"
@@ -59,14 +60,30 @@ func NewNodeServiceCapability(cap csi.NodeServiceCapability_RPC_Type) *csi.NodeS
59
60
}
60
61
}
61
62
63
+ // Reflect magic below simply clears Secrets map from request.
64
+ func clearSecrets (req interface {}) interface {} {
65
+ v := reflect .ValueOf (& req ).Elem ()
66
+ e := reflect .New (v .Elem ().Type ()).Elem ()
67
+ e .Set (v .Elem ())
68
+ f := reflect .Indirect (e ).FieldByName ("Secrets" )
69
+ if f .IsValid () && f .CanSet () && f .Kind () == reflect .Map {
70
+ f .Set (reflect .MakeMap (f .Type ()))
71
+ v .Set (e )
72
+ }
73
+ return req
74
+ }
75
+
62
76
func logGRPC (ctx context.Context , req interface {}, info * grpc.UnaryServerInfo , handler grpc.UnaryHandler ) (interface {}, error ) {
63
77
if info .FullMethod == ProbeCSIFullMethod {
64
78
return handler (ctx , req )
65
79
}
66
- // Note that secrets are not included in any RPC message. In the past protosanitizer and other log
80
+ // Note that secrets may be included in some RPC messages
81
+ // (https://github.com/kubernetes-sigs/gcp-compute-persistent-disk-csi-driver/issues/1372),
82
+ // but the driver ignores them. In the past protosanitizer and other log
67
83
// stripping was shown to cause a significant increase of CPU usage (see
68
84
// https://github.com/kubernetes-sigs/gcp-compute-persistent-disk-csi-driver/issues/356#issuecomment-550529004).
69
- klog .V (4 ).Infof ("%s called with request: %s" , info .FullMethod , req )
85
+ // That is why we use hand-crafted clearSecrets() below rather than protosanitizer.
86
+ klog .V (4 ).Infof ("%s called with request: %s" , info .FullMethod , clearSecrets (req ))
70
87
resp , err := handler (ctx , req )
71
88
if err != nil {
72
89
klog .Errorf ("%s returned with error: %v" , info .FullMethod , err .Error ())
0 commit comments