in pkg/csi_driver/utils.go [97:133]
func logGRPC(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {
var strippedReq string
switch info.FullMethod {
case CreateVolumeCSIFullMethod:
strippedReq = pbSanitizer.StripSecrets(req).String()
case DeleteVolumeCSIFullMethod:
strippedReq = pbSanitizer.StripSecrets(req).String()
case NodePublishVolumeCSIFullMethod:
if nodePublishReq, ok := req.(*csi.NodePublishVolumeRequest); ok {
if token, ok := nodePublishReq.GetVolumeContext()[VolumeContextKeyServiceAccountToken]; ok {
nodePublishReq.VolumeContext[VolumeContextKeyServiceAccountToken] = "***stripped***"
strippedReq = fmt.Sprintf("%+v", nodePublishReq)
nodePublishReq.VolumeContext[VolumeContextKeyServiceAccountToken] = token
} else {
strippedReq = fmt.Sprintf("%+v", req)
}
} else {
klog.Errorf("failed to case req to *csi.NodePublishVolumeRequest")
}
default:
strippedReq = fmt.Sprintf("%+v", req)
}
klog.V(4).Infof("%s called with request: %v", info.FullMethod, strippedReq)
resp, err := handler(ctx, req)
if err != nil {
klog.Errorf("%s failed with error: %v", info.FullMethod, err)
} else {
if fmt.Sprintf("%v", resp) == "" {
klog.V(4).Infof("%s succeeded.", info.FullMethod)
} else {
klog.V(4).Infof("%s succeeded with response: %s", info.FullMethod, resp)
}
}
return resp, err
}