Switch all logging to use containerd log pkg

This unifies our logging and allows us to propagate logging and trace
contexts together.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
This commit is contained in:
Brian Goff
2023-06-23 00:33:17 +00:00
parent 8d070e30f5
commit 74da6a6363
304 changed files with 2062 additions and 1826 deletions

View File

@@ -4,12 +4,12 @@ import (
"context"
"time"
"github.com/containerd/containerd/log"
containertypes "github.com/docker/docker/api/types/container"
"github.com/docker/docker/container"
"github.com/docker/docker/errdefs"
"github.com/moby/sys/signal"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
)
// ContainerStop looks for the given container and stops it.
@@ -94,7 +94,7 @@ func (daemon *Daemon) containerStop(_ context.Context, ctr *container.Container,
if err != nil {
// the container has still not exited, and the kill function errored, so log the error here:
logrus.WithError(err).WithField("container", ctr.ID).Errorf("Error sending stop (signal %d) to container", stopSignal)
log.G(ctx).WithError(err).WithField("container", ctr.ID).Errorf("Error sending stop (signal %d) to container", stopSignal)
}
if stopTimeout < 0 {
// if the client requested that we never kill / wait forever, but container.Wait was still
@@ -102,7 +102,7 @@ func (daemon *Daemon) containerStop(_ context.Context, ctr *container.Container,
return err
}
logrus.WithField("container", ctr.ID).Infof("Container failed to exit within %s of signal %d - using the force", wait, stopSignal)
log.G(ctx).WithField("container", ctr.ID).Infof("Container failed to exit within %s of signal %d - using the force", wait, stopSignal)
// Stop either failed or container didn't exit, so fallback to kill.
if err := daemon.Kill(ctr); err != nil {
@@ -111,7 +111,7 @@ func (daemon *Daemon) containerStop(_ context.Context, ctr *container.Container,
defer cancel()
status := <-ctr.Wait(subCtx, container.WaitConditionNotRunning)
if status.Err() != nil {
logrus.WithError(err).WithField("container", ctr.ID).Errorf("error killing container: %v", status.Err())
log.G(ctx).WithError(err).WithField("container", ctr.ID).Errorf("error killing container: %v", status.Err())
return err
}
// container did exit, so ignore previous errors and continue