-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fan out events in async mode for async recordings.
This commit fixes #4695. Teleport in async recording mode sends all events to disk, and uploads them to the server later. It uploads some events synchronously to the audit log so they show up in the global event log right away. However if the auth server is slow, the fanout blocks the session. This commit makes the fanout of some events to be fast, but nonblocking and never fail so sessions will not hang unless the disk writes hang. It also adds ability to debug GRPC connection state when running in debug mode. To start sending GRPC connection state logs, set environment variables: GRPC_GO_LOG_SEVERITY_LEVEL=info GRPC_GO_LOG_VERBOSITY_LEVEL=99 teleport start -d
- Loading branch information
1 parent
ecb165f
commit 0082311
Showing
7 changed files
with
301 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
Copyright 2020 Gravitational, Inc. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package service | ||
|
||
import ( | ||
"io" | ||
"io/ioutil" | ||
"os" | ||
"strconv" | ||
|
||
// import to call client v3 init section | ||
_ "go.etcd.io/etcd/clientv3" | ||
"google.golang.org/grpc/grpclog" | ||
) | ||
|
||
// setGRPCLogger sets GRPC logger to writer and sets | ||
// severity using env variables from https://pkg.go.dev/google.golang.org/grpc/grpclog | ||
// | ||
// GRPC client logger is pretty verbose, so only call this in debug mode. | ||
// | ||
// etcd client overrides GRPC logger to discard in init | ||
// section. That's why setGRPCLogger is called after etcd client's init | ||
// call and sets it to writer, while taking GRPC standard | ||
// environment variables into account. | ||
func setDebugGRPCLogger(w io.Writer) { | ||
errorW := ioutil.Discard | ||
warningW := ioutil.Discard | ||
infoW := ioutil.Discard | ||
|
||
logLevel := os.Getenv("GRPC_GO_LOG_SEVERITY_LEVEL") | ||
|
||
switch logLevel { | ||
case "", "ERROR", "error": // If env is unset, set level to ERROR. | ||
errorW = os.Stderr | ||
case "WARNING", "warning": | ||
warningW = os.Stderr | ||
case "INFO", "info": | ||
infoW = os.Stderr | ||
} | ||
|
||
var v int | ||
vLevel := os.Getenv("GRPC_GO_LOG_VERBOSITY_LEVEL") | ||
if vl, err := strconv.Atoi(vLevel); err == nil { | ||
v = vl | ||
} | ||
|
||
l := grpclog.NewLoggerV2WithVerbosity(infoW, warningW, errorW, v) | ||
grpclog.SetLoggerV2(l) | ||
} |
Oops, something went wrong.