Skip to content

Commit

Permalink
Move certain debug logs to trace logs
Browse files Browse the repository at this point in the history
Signed-off-by: Kirtana Ashok <kiashok@microsoft.com>
(cherry picked from commit f261969)
  • Loading branch information
kiashok committed Feb 5, 2024
1 parent 7c3aca7 commit 3f75af7
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 18 deletions.
8 changes: 4 additions & 4 deletions cmd/ctr/commands/content/content.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion gc/scheduler/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions metadata/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
Expand Down
18 changes: 9 additions & 9 deletions pkg/cri/instrument/instrumented_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
}()
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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")
}
}()

Expand All @@ -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")
}
}()

Expand Down
3 changes: 2 additions & 1 deletion pkg/cri/io/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/cri/server/container_execsync.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 3f75af7

Please sign in to comment.