Discard grpc logs by default
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
This commit is contained in:
parent
709ba260de
commit
c9064df2cf
@ -5,8 +5,6 @@ package linux
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
|
||||||
"net"
|
"net"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@ -14,11 +12,10 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
"google.golang.org/grpc/grpclog"
|
|
||||||
|
|
||||||
"github.com/containerd/containerd/api/services/shim"
|
"github.com/containerd/containerd/api/services/shim"
|
||||||
localShim "github.com/containerd/containerd/linux/shim"
|
localShim "github.com/containerd/containerd/linux/shim"
|
||||||
containerdlog "github.com/containerd/containerd/log"
|
"github.com/containerd/containerd/log"
|
||||||
"github.com/containerd/containerd/reaper"
|
"github.com/containerd/containerd/reaper"
|
||||||
"github.com/containerd/containerd/sys"
|
"github.com/containerd/containerd/sys"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
@ -58,7 +55,7 @@ func newShim(ctx context.Context, shimName string, path, namespace string, remot
|
|||||||
cmd.Process.Kill()
|
cmd.Process.Kill()
|
||||||
reaper.Default.Wait(cmd)
|
reaper.Default.Wait(cmd)
|
||||||
} else {
|
} else {
|
||||||
containerdlog.G(ctx).WithField("socket", socket).Infof("new shim started")
|
log.G(ctx).WithField("socket", socket).Infof("new shim started")
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
if err = sys.SetOOMScore(cmd.Process.Pid, sys.OOMScoreMaxKillable); err != nil {
|
if err = sys.SetOOMScore(cmd.Process.Pid, sys.OOMScoreMaxKillable); err != nil {
|
||||||
@ -77,7 +74,6 @@ func loadShim(path, namespace string, remote bool) (shim.ShimClient, error) {
|
|||||||
|
|
||||||
func connectShim(socket string) (shim.ShimClient, error) {
|
func connectShim(socket string) (shim.ShimClient, error) {
|
||||||
// reset the logger for grpc to log to dev/null so that it does not mess with our stdio
|
// reset the logger for grpc to log to dev/null so that it does not mess with our stdio
|
||||||
grpclog.SetLogger(log.New(ioutil.Discard, "", log.LstdFlags))
|
|
||||||
dialOpts := []grpc.DialOption{grpc.WithInsecure(), grpc.WithTimeout(100 * time.Second)}
|
dialOpts := []grpc.DialOption{grpc.WithInsecure(), grpc.WithTimeout(100 * time.Second)}
|
||||||
dialOpts = append(dialOpts,
|
dialOpts = append(dialOpts,
|
||||||
grpc.WithDialer(func(addr string, timeout time.Duration) (net.Conn, error) {
|
grpc.WithDialer(func(addr string, timeout time.Duration) (net.Conn, error) {
|
||||||
|
@ -1,14 +1,12 @@
|
|||||||
package log
|
package log
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"io/ioutil"
|
||||||
|
"log"
|
||||||
|
|
||||||
"google.golang.org/grpc/grpclog"
|
"google.golang.org/grpc/grpclog"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
ctx := WithModule(context.Background(), "grpc")
|
grpclog.SetLogger(log.New(ioutil.Discard, "", log.LstdFlags))
|
||||||
|
|
||||||
// completely replace the grpc logger with the logrus logger.
|
|
||||||
grpclog.SetLogger(G(ctx))
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user