Skip to content

Commit

Permalink
Merge pull request containerd#9762 from kiashok/portLogChanges-1.6
Browse files Browse the repository at this point in the history
[release/1.6] Move certain debug logs to trace logs
  • Loading branch information
AkihiroSuda authored Feb 6, 2024
2 parents ae07eda + 195ef76 commit 7d7cbe0
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 19 deletions.
6 changes: 3 additions & 3 deletions cmd/ctr/commands/content/content.go
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,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 @@ -430,7 +430,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 @@ -471,7 +471,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 @@ -326,7 +326,7 @@ func (s *gcScheduler) run(ctx context.Context) {
continue
}

log.G(ctx).WithField("d", stats.Elapsed()).Debug("garbage collected")
log.G(ctx).WithField("d", stats.Elapsed()).Trace("garbage collected")

gcTime += stats.Elapsed()
collections++
Expand Down
4 changes: 2 additions & 2 deletions metadata/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ func (m *DB) cleanupSnapshotter(name string) (time.Duration, error) {
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 @@ -439,7 +439,7 @@ func (m *DB) cleanupContent() (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
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
25 changes: 13 additions & 12 deletions pkg/cri/server/instrumented_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -734,12 +734,12 @@ func (in *instrumentedService) ExecSync(ctx context.Context, r *runtime.ExecSync
if err := in.checkInitialized(); err != nil {
return nil, err
}
log.G(ctx).Debugf("ExecSync for %q with command %+v and timeout %d (s)", r.GetContainerId(), r.GetCmd(), r.GetTimeout())
log.G(ctx).Tracef("ExecSync for %q with command %+v and timeout %d (s)", r.GetContainerId(), r.GetCmd(), r.GetTimeout())
defer func() {
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 @@ -1166,12 +1166,13 @@ func (in *instrumentedService) ImageFsInfo(ctx context.Context, r *runtime.Image
if err := in.checkInitialized(); err != nil {
return nil, err
}
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)
}
}()
res, err = in.c.ImageFsInfo(ctrdutil.WithNamespace(ctx), r)
Expand Down Expand Up @@ -1219,12 +1220,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 All @@ -1235,12 +1236,12 @@ func (in *instrumentedAlphaService) PodSandboxStats(ctx context.Context, r *runt
if err := in.checkInitialized(ctx); 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())
}
}()
// converts request and response for earlier CRI version to call and get response from the current version
Expand Down Expand Up @@ -1272,12 +1273,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 All @@ -1288,12 +1289,12 @@ func (in *instrumentedAlphaService) ContainerStats(ctx context.Context, r *runti
if err := in.checkInitialized(ctx); 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())
}
}()
// converts request and response for earlier CRI version to call and get response from the current version
Expand Down

0 comments on commit 7d7cbe0

Please sign in to comment.