shim: Respect containerd's debug config

There are too many logs from kata shim in containerd's log.
Fixes #2209

Signed-off-by: choury <chouryzhou@tencent.com>
This commit is contained in:
choury 2019-11-18 22:16:38 +08:00 committed by choury
parent 547d580ad5
commit 51d7c23e41

View File

@ -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 // it will output into stdio, from which containerd would like
// to get the shim's socket address. // to get the shim's socket address.
logrus.SetOutput(ioutil.Discard) logrus.SetOutput(ioutil.Discard)
opts := ctx.Value(cdshim.OptsKey{}).(cdshim.Opts)
if !opts.Debug {
logrus.SetLevel(logrus.WarnLevel)
}
vci.SetLogger(ctx, logger) vci.SetLogger(ctx, logger)
katautils.SetLogger(ctx, logger, logger.Logger.Level) katautils.SetLogger(ctx, logger, logger.Logger.Level)
@ -141,7 +145,10 @@ func newCommand(ctx context.Context, containerdBinary, id, containerdAddress str
"-address", containerdAddress, "-address", containerdAddress,
"-publish-binary", containerdBinary, "-publish-binary", containerdBinary,
"-id", id, "-id", id,
"-debug", }
opts := ctx.Value(cdshim.OptsKey{}).(cdshim.Opts)
if opts.Debug {
args = append(args, "-debug")
} }
cmd := sysexec.Command(self, args...) cmd := sysexec.Command(self, args...)
cmd.Dir = cwd cmd.Dir = cwd