From 3f75af7bf20fc6d1456e282e31c51d32d086b9ec Mon Sep 17 00:00:00 2001 From: Kirtana Ashok Date: Wed, 10 Jan 2024 14:43:54 -0800 Subject: [PATCH] Move certain debug logs to trace logs Signed-off-by: Kirtana Ashok (cherry picked from commit f26196950705559c61ca7b246b1d1700638760b9) --- cmd/ctr/commands/content/content.go | 8 ++++---- gc/scheduler/scheduler.go | 2 +- metadata/db.go | 4 ++-- pkg/cri/instrument/instrumented_service.go | 18 +++++++++--------- pkg/cri/io/logger.go | 3 ++- pkg/cri/server/container_execsync.go | 2 +- 6 files changed, 19 insertions(+), 18 deletions(-) diff --git a/cmd/ctr/commands/content/content.go b/cmd/ctr/commands/content/content.go index d4cfa92fb1..480e134f93 100644 --- a/cmd/ctr/commands/content/content.go +++ b/cmd/ctr/commands/content/content.go @@ -424,7 +424,7 @@ var ( ctx = log.WithLogger(ctx, log.G(ctx).WithField("ref", ref)) - log.G(ctx).Debugf("resolving") + log.G(ctx).Tracef("resolving") name, desc, err := resolver.Resolve(ctx, ref) if err != nil { return err @@ -434,7 +434,7 @@ var ( return err } - log.G(ctx).Debugf("fetching") + log.G(ctx).Tracef("fetching") rc, err := fetcher.Fetch(ctx, desc) if err != nil { return err @@ -470,7 +470,7 @@ var ( ctx = log.WithLogger(ctx, log.G(ctx).WithField("ref", ref)) - log.G(ctx).Debugf("resolving") + log.G(ctx).Tracef("resolving") fetcher, err := resolver.Fetcher(ctx, ref) if err != nil { return err @@ -529,7 +529,7 @@ var ( ctx = log.WithLogger(ctx, log.G(ctx).WithField("ref", ref)) - log.G(ctx).Debugf("resolving") + log.G(ctx).Tracef("resolving") pusher, err := resolver.Pusher(ctx, ref) if err != nil { return err diff --git a/gc/scheduler/scheduler.go b/gc/scheduler/scheduler.go index 4a72906a49..af563dd96c 100644 --- a/gc/scheduler/scheduler.go +++ b/gc/scheduler/scheduler.go @@ -328,7 +328,7 @@ func (s *gcScheduler) run(ctx context.Context) { gcTime := stats.Elapsed() gcTimeHist.Update(gcTime) - log.G(ctx).WithField("d", gcTime).Debug("garbage collected") + log.G(ctx).WithField("d", gcTime).Trace("garbage collected") gcTimeSum += gcTime collections++ collectionCounter.WithValues("success").Inc() diff --git a/metadata/db.go b/metadata/db.go index 8241930a96..83b614fd13 100644 --- a/metadata/db.go +++ b/metadata/db.go @@ -520,7 +520,7 @@ func (m *DB) cleanupSnapshotter(ctx context.Context, name string) (time.Duration if err != nil { logger.WithError(err).Warn("snapshot garbage collection failed") } else { - logger.WithField("d", d).Debugf("snapshot garbage collected") + logger.WithField("d", d).Tracef("snapshot garbage collected") } return d, err } @@ -535,7 +535,7 @@ func (m *DB) cleanupContent(ctx context.Context) (time.Duration, error) { if err != nil { log.G(ctx).WithError(err).Warn("content garbage collection failed") } else { - log.G(ctx).WithField("d", d).Debugf("content garbage collected") + log.G(ctx).WithField("d", d).Tracef("content garbage collected") } return d, err diff --git a/pkg/cri/instrument/instrumented_service.go b/pkg/cri/instrument/instrumented_service.go index 7eb217235e..51a7fc865e 100644 --- a/pkg/cri/instrument/instrumented_service.go +++ b/pkg/cri/instrument/instrumented_service.go @@ -768,7 +768,7 @@ func (in *instrumentedService) ExecSync(ctx context.Context, r *runtime.ExecSync if err != nil { log.G(ctx).WithError(err).Errorf("ExecSync for %q failed", r.GetContainerId()) } else { - log.G(ctx).Debugf("ExecSync for %q returns with exit code %d", r.GetContainerId(), res.GetExitCode()) + log.G(ctx).Tracef("ExecSync for %q returns with exit code %d", r.GetContainerId(), res.GetExitCode()) } }() res, err = in.c.ExecSync(ctrdutil.WithNamespace(ctx), r) @@ -1221,12 +1221,12 @@ func (in *instrumentedService) ImageFsInfo(ctx context.Context, r *runtime.Image } ctx, span := tracing.StartSpan(ctx, tracing.Name(criSpanPrefix, "ImageFsInfo")) defer span.End() - log.G(ctx).Debugf("ImageFsInfo") + log.G(ctx).Tracef("ImageFsInfo") defer func() { if err != nil { log.G(ctx).WithError(err).Error("ImageFsInfo failed") } else { - log.G(ctx).Debugf("ImageFsInfo returns filesystem info %+v", res.ImageFilesystems) + log.G(ctx).Tracef("ImageFsInfo returns filesystem info %+v", res.ImageFilesystems) } span.SetStatus(err) }() @@ -1278,12 +1278,12 @@ func (in *instrumentedService) PodSandboxStats(ctx context.Context, r *runtime.P if err := in.checkInitialized(); err != nil { return nil, err } - log.G(ctx).Debugf("PodSandboxStats for %q", r.GetPodSandboxId()) + log.G(ctx).Tracef("PodSandboxStats for %q", r.GetPodSandboxId()) defer func() { if err != nil { log.G(ctx).WithError(err).Errorf("PodSandboxStats for %q failed", r.GetPodSandboxId()) } else { - log.G(ctx).Debugf("PodSandboxStats for %q returns stats %+v", r.GetPodSandboxId(), res.GetStats()) + log.G(ctx).Tracef("PodSandboxStats for %q returns stats %+v", r.GetPodSandboxId(), res.GetStats()) } }() res, err = in.c.PodSandboxStats(ctrdutil.WithNamespace(ctx), r) @@ -1331,12 +1331,12 @@ func (in *instrumentedService) ContainerStats(ctx context.Context, r *runtime.Co if err := in.checkInitialized(); err != nil { return nil, err } - log.G(ctx).Debugf("ContainerStats for %q", r.GetContainerId()) + log.G(ctx).Tracef("ContainerStats for %q", r.GetContainerId()) defer func() { if err != nil { log.G(ctx).WithError(err).Errorf("ContainerStats for %q failed", r.GetContainerId()) } else { - log.G(ctx).Debugf("ContainerStats for %q returns stats %+v", r.GetContainerId(), res.GetStats()) + log.G(ctx).Tracef("ContainerStats for %q returns stats %+v", r.GetContainerId(), res.GetStats()) } }() res, err = in.c.ContainerStats(ctrdutil.WithNamespace(ctx), r) @@ -1721,7 +1721,7 @@ func (in *instrumentedService) ListMetricDescriptors(ctx context.Context, r *run if err != nil { log.G(ctx).WithError(err).Errorf("ListMetricDescriptors failed, error") } else { - log.G(ctx).Debug("ListMetricDescriptors returns successfully") + log.G(ctx).Trace("ListMetricDescriptors returns successfully") } }() @@ -1738,7 +1738,7 @@ func (in *instrumentedService) ListPodSandboxMetrics(ctx context.Context, r *run if err != nil { log.G(ctx).WithError(err).Errorf("ListPodSandboxMetrics failed, error") } else { - log.G(ctx).Debug("ListPodSandboxMetrics returns successfully") + log.G(ctx).Trace("ListPodSandboxMetrics returns successfully") } }() diff --git a/pkg/cri/io/logger.go b/pkg/cri/io/logger.go index 3f905e4995..34c645b4fd 100644 --- a/pkg/cri/io/logger.go +++ b/pkg/cri/io/logger.go @@ -26,6 +26,7 @@ import ( "github.com/sirupsen/logrus" runtime "k8s.io/cri-api/pkg/apis/runtime/v1" + "github.com/containerd/containerd/log" cioutil "github.com/containerd/containerd/pkg/ioutil" ) @@ -167,7 +168,7 @@ func redirectLogs(path string, rc io.ReadCloser, w io.Writer, s StreamType, maxL } if err != nil { if err == io.EOF { - logrus.Debugf("Getting EOF from stream %q while redirecting to log file %q", s, path) + log.L.Tracef("Getting EOF from stream %q while redirecting to log file %q", s, path) } else { logrus.WithError(err).Errorf("An error occurred when redirecting stream %q to log file %q", s, path) } diff --git a/pkg/cri/server/container_execsync.go b/pkg/cri/server/container_execsync.go index b222815451..2b1b6559fd 100644 --- a/pkg/cri/server/container_execsync.go +++ b/pkg/cri/server/container_execsync.go @@ -293,7 +293,7 @@ func drainExecSyncIO(ctx context.Context, execProcess containerd.Process, drainE select { case <-timerCh: case <-attachDone: - log.G(ctx).Debugf("Stream pipe for exec process %q done", execProcess.ID()) + log.G(ctx).Tracef("Stream pipe for exec process %q done", execProcess.ID()) return nil }