From 51d7c23e418f9c86eb4d737d2c8f6ece13e2ee70 Mon Sep 17 00:00:00 2001 From: choury Date: Mon, 18 Nov 2019 22:16:38 +0800 Subject: [PATCH] shim: Respect containerd's debug config There are too many logs from kata shim in containerd's log. Fixes #2209 Signed-off-by: choury --- containerd-shim-v2/service.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/containerd-shim-v2/service.go b/containerd-shim-v2/service.go index 4ffccbea9b..af26d94ef5 100644 --- a/containerd-shim-v2/service.go +++ b/containerd-shim-v2/service.go @@ -65,6 +65,10 @@ func New(ctx context.Context, id string, publisher events.Publisher) (cdshim.Shi // it will output into stdio, from which containerd would like // to get the shim's socket address. logrus.SetOutput(ioutil.Discard) + opts := ctx.Value(cdshim.OptsKey{}).(cdshim.Opts) + if !opts.Debug { + logrus.SetLevel(logrus.WarnLevel) + } vci.SetLogger(ctx, logger) katautils.SetLogger(ctx, logger, logger.Logger.Level) @@ -141,7 +145,10 @@ func newCommand(ctx context.Context, containerdBinary, id, containerdAddress str "-address", containerdAddress, "-publish-binary", containerdBinary, "-id", id, - "-debug", + } + opts := ctx.Value(cdshim.OptsKey{}).(cdshim.Opts) + if opts.Debug { + args = append(args, "-debug") } cmd := sysexec.Command(self, args...) cmd.Dir = cwd