Merge pull request #9016 from djdongjin/remove-most-logrus
Remove most logrus import
This commit is contained in:
commit
e30a40eb65
@ -114,7 +114,7 @@ func init() {
|
||||
if hook, err := etwlogrus.NewHookFromProvider(provider); err == nil {
|
||||
logrus.AddHook(hook)
|
||||
} else {
|
||||
logrus.Error(err)
|
||||
log.L.Error(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -37,9 +37,9 @@ import (
|
||||
"github.com/containerd/containerd/cmd/ctr/commands/tasks"
|
||||
versionCmd "github.com/containerd/containerd/cmd/ctr/commands/version"
|
||||
"github.com/containerd/containerd/defaults"
|
||||
"github.com/containerd/containerd/log"
|
||||
"github.com/containerd/containerd/namespaces"
|
||||
"github.com/containerd/containerd/version"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/urfave/cli"
|
||||
"google.golang.org/grpc/grpclog"
|
||||
)
|
||||
@ -121,7 +121,7 @@ containerd CLI
|
||||
}, extraCmds...)
|
||||
app.Before = func(context *cli.Context) error {
|
||||
if context.GlobalBool("debug") {
|
||||
logrus.SetLevel(logrus.DebugLevel)
|
||||
return log.SetLevel("debug")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -25,7 +25,6 @@ import (
|
||||
"github.com/containerd/containerd/content"
|
||||
"github.com/containerd/containerd/leases"
|
||||
"github.com/containerd/containerd/log"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
@ -66,7 +65,7 @@ var pruneReferencesCommand = cli.Command{
|
||||
|
||||
dryRun := clicontext.Bool("dry")
|
||||
if dryRun {
|
||||
log.G(ctx).Logger.SetLevel(logrus.DebugLevel)
|
||||
log.G(ctx).Logger.SetLevel(log.DebugLevel)
|
||||
log.G(ctx).Debug("dry run, no changes will be applied")
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,6 @@ import (
|
||||
"github.com/containerd/containerd/filters"
|
||||
"github.com/containerd/containerd/log"
|
||||
"github.com/containerd/containerd/pkg/randutil"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/opencontainers/go-digest"
|
||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
@ -555,7 +554,7 @@ func (s *store) writer(ctx context.Context, ref string, total int64, expected di
|
||||
total = status.Total
|
||||
offset = status.Offset
|
||||
} else {
|
||||
logrus.Infof("failed to resume the status from path %s: %s. will recreate them", path, err.Error())
|
||||
log.G(ctx).Infof("failed to resume the status from path %s: %s. will recreate them", path, err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ import (
|
||||
"path"
|
||||
|
||||
fuzz "github.com/AdaLogics/go-fuzz-headers"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/containerd/containerd/log"
|
||||
|
||||
"github.com/containerd/containerd/archive"
|
||||
"github.com/containerd/containerd/content/local"
|
||||
@ -42,7 +42,7 @@ func FuzzApply(data []byte) int {
|
||||
// if the input is random.
|
||||
//
|
||||
// level=warning msg="ignored xattr ... in archive" error="operation not supported"
|
||||
log.G(ctx).Logger.SetLevel(logrus.PanicLevel)
|
||||
log.G(ctx).Logger.SetLevel(log.PanicLevel)
|
||||
|
||||
f := fuzz.NewConsumer(data)
|
||||
iters, err := f.GetInt()
|
||||
|
@ -26,10 +26,10 @@ import (
|
||||
|
||||
"github.com/containerd/containerd/content"
|
||||
"github.com/containerd/containerd/images"
|
||||
"github.com/containerd/containerd/log"
|
||||
"github.com/containerd/containerd/platforms"
|
||||
"github.com/opencontainers/go-digest"
|
||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
"github.com/sirupsen/logrus"
|
||||
"golang.org/x/sync/errgroup"
|
||||
)
|
||||
|
||||
@ -123,7 +123,7 @@ func (c *defaultConverter) convert(ctx context.Context, cs content.Store, desc o
|
||||
newDesc.Annotations = nil
|
||||
}
|
||||
}
|
||||
logrus.WithField("old", desc).WithField("new", newDesc).Debugf("converted")
|
||||
log.G(ctx).WithField("old", desc).WithField("new", newDesc).Debugf("converted")
|
||||
return newDesc, nil
|
||||
}
|
||||
|
||||
|
@ -22,8 +22,8 @@ import (
|
||||
"os"
|
||||
"sync"
|
||||
|
||||
"github.com/containerd/containerd/log"
|
||||
"github.com/pelletier/go-toml"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
var imageListFile = flag.String("image-list", "", "The TOML file containing the non-default images to be used in tests.")
|
||||
@ -58,7 +58,7 @@ func initImages(imageListFile string) {
|
||||
}
|
||||
|
||||
if imageListFile != "" {
|
||||
logrus.Infof("loading image list from file: %s", imageListFile)
|
||||
log.L.Infof("loading image list from file: %s", imageListFile)
|
||||
|
||||
fileContent, err := os.ReadFile(imageListFile)
|
||||
if err != nil {
|
||||
@ -71,7 +71,7 @@ func initImages(imageListFile string) {
|
||||
}
|
||||
}
|
||||
|
||||
logrus.Infof("Using the following image list: %+v", imageList)
|
||||
log.L.Infof("Using the following image list: %+v", imageList)
|
||||
imageMap = initImageMap(imageList)
|
||||
}
|
||||
|
||||
|
@ -39,12 +39,12 @@ import (
|
||||
_ "github.com/containerd/containerd/integration/images" // Keep this around to parse `imageListFile` command line var
|
||||
"github.com/containerd/containerd/integration/remote"
|
||||
dialer "github.com/containerd/containerd/integration/remote/util"
|
||||
"github.com/containerd/containerd/log"
|
||||
criconfig "github.com/containerd/containerd/pkg/cri/config"
|
||||
"github.com/containerd/containerd/pkg/cri/constants"
|
||||
"github.com/containerd/containerd/pkg/cri/server"
|
||||
"github.com/containerd/containerd/pkg/cri/util"
|
||||
"github.com/opencontainers/selinux/go-selinux"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
exec "golang.org/x/sys/execabs"
|
||||
@ -72,7 +72,7 @@ var containerdBin = flag.String("containerd-bin", "containerd", "The containerd
|
||||
func TestMain(m *testing.M) {
|
||||
flag.Parse()
|
||||
if err := ConnectDaemons(); err != nil {
|
||||
logrus.WithError(err).Fatalf("Failed to connect daemons")
|
||||
log.L.WithError(err).Fatalf("Failed to connect daemons")
|
||||
}
|
||||
os.Exit(m.Run())
|
||||
}
|
||||
|
@ -25,9 +25,9 @@ import (
|
||||
"golang.org/x/sys/unix"
|
||||
|
||||
cgroups "github.com/containerd/cgroups/v3/cgroup1"
|
||||
"github.com/containerd/containerd/log"
|
||||
metrics "github.com/docker/go-metrics"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func newOOMCollector(ns *metrics.Namespace) (*oomCollector, error) {
|
||||
@ -116,7 +116,7 @@ func (o *oomCollector) start() {
|
||||
if err == unix.EINTR {
|
||||
continue
|
||||
}
|
||||
logrus.WithError(err).Error("cgroups: epoll wait failed, OOM notifications disabled")
|
||||
log.L.WithError(err).Error("cgroups: epoll wait failed, OOM notifications disabled")
|
||||
return
|
||||
}
|
||||
for i := 0; i < n; i++ {
|
||||
|
@ -24,7 +24,6 @@ import (
|
||||
|
||||
"github.com/containerd/containerd/cio"
|
||||
"github.com/containerd/containerd/log"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/containerd/containerd/pkg/cri/util"
|
||||
cioutil "github.com/containerd/containerd/pkg/ioutil"
|
||||
@ -161,7 +160,7 @@ func (c *ContainerIO) Attach(opts AttachOptions) {
|
||||
c.stdin.Close()
|
||||
// Also closes the containerd side.
|
||||
if err := opts.CloseStdin(); err != nil {
|
||||
logrus.WithError(err).Errorf("Failed to close stdin for container %q", c.id)
|
||||
log.L.WithError(err).Errorf("Failed to close stdin for container %q", c.id)
|
||||
}
|
||||
} else {
|
||||
if opts.Stdout != nil {
|
||||
@ -177,7 +176,7 @@ func (c *ContainerIO) Attach(opts AttachOptions) {
|
||||
|
||||
attachStream := func(key string, close <-chan struct{}) {
|
||||
<-close
|
||||
logrus.Infof("Attach stream %q closed", key)
|
||||
log.L.Infof("Attach stream %q closed", key)
|
||||
// Make sure stdin gets closed.
|
||||
if stdinStreamRC != nil {
|
||||
stdinStreamRC.Close()
|
||||
|
@ -23,9 +23,9 @@ import (
|
||||
"io"
|
||||
"time"
|
||||
|
||||
"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"
|
||||
)
|
||||
|
||||
@ -51,7 +51,7 @@ func NewDiscardLogger() io.WriteCloser {
|
||||
// maxLen is the max length limit of a line. A line longer than the
|
||||
// limit will be cut into multiple lines.
|
||||
func NewCRILogger(path string, w io.Writer, stream StreamType, maxLen int) (io.WriteCloser, <-chan struct{}) {
|
||||
logrus.Debugf("Start writing stream %q to log file %q", stream, path)
|
||||
log.L.Debugf("Start writing stream %q to log file %q", stream, path)
|
||||
prc, pwc := io.Pipe()
|
||||
stop := make(chan struct{})
|
||||
go func() {
|
||||
@ -147,7 +147,7 @@ func redirectLogs(path string, rc io.ReadCloser, w io.Writer, s StreamType, maxL
|
||||
outputEntries.Inc()
|
||||
outputBytes.Inc(float64(n))
|
||||
} else {
|
||||
logrus.WithError(err).Errorf("Fail to write %q log to log file %q", s, path)
|
||||
log.L.WithError(err).Errorf("Fail to write %q log to log file %q", s, path)
|
||||
// Continue on write error to drain the container output.
|
||||
}
|
||||
}
|
||||
@ -167,9 +167,9 @@ 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.Debugf("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)
|
||||
log.L.WithError(err).Errorf("An error occurred when redirecting stream %q to log file %q", s, path)
|
||||
}
|
||||
if length == 0 {
|
||||
// No content left to write, break.
|
||||
@ -209,5 +209,5 @@ func redirectLogs(path string, rc io.ReadCloser, w io.Writer, s StreamType, maxL
|
||||
break
|
||||
}
|
||||
}
|
||||
logrus.Debugf("Finish redirecting stream %q to log file %q", s, path)
|
||||
log.L.Debugf("Finish redirecting stream %q to log file %q", s, path)
|
||||
}
|
||||
|
@ -29,7 +29,6 @@ import (
|
||||
"github.com/containerd/containerd/pkg/kmutex"
|
||||
"github.com/containerd/containerd/reference/docker"
|
||||
imagedigest "github.com/opencontainers/go-digest"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
type CRIImageService struct {
|
||||
@ -64,7 +63,7 @@ func NewService(config criconfig.Config, imageFSPath string, client *containerd.
|
||||
}
|
||||
|
||||
// Start snapshot stats syncer, it doesn't need to be stopped.
|
||||
logrus.Info("Start snapshots syncer")
|
||||
log.L.Info("Start snapshots syncer")
|
||||
snapshotsSyncer := newSnapshotsSyncer(
|
||||
svc.snapshotStore,
|
||||
svc.client.SnapshotService(svc.config.ContainerdConfig.Snapshotter),
|
||||
|
@ -33,7 +33,6 @@ import (
|
||||
ctrdutil "github.com/containerd/containerd/pkg/cri/util"
|
||||
"github.com/containerd/containerd/reference/docker"
|
||||
runtimespec "github.com/opencontainers/runtime-spec/specs-go"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
||||
imagedigest "github.com/opencontainers/go-digest"
|
||||
)
|
||||
@ -111,7 +110,7 @@ func buildLabels(configLabels, imageConfigLabels map[string]string, containerTyp
|
||||
} else {
|
||||
// In case the image label is invalid, we output a warning and skip adding it to the
|
||||
// container.
|
||||
logrus.WithError(err).Warnf("unable to add image label with key %s to the container", k)
|
||||
log.L.WithError(err).Warnf("unable to add image label with key %s to the container", k)
|
||||
}
|
||||
}
|
||||
// labels from the CRI request (config) will override labels in the image config
|
||||
|
@ -22,10 +22,9 @@ import (
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
|
||||
eventtypes "github.com/containerd/containerd/api/events"
|
||||
"github.com/containerd/containerd/errdefs"
|
||||
"github.com/containerd/containerd/log"
|
||||
sandboxstore "github.com/containerd/containerd/pkg/cri/store/sandbox"
|
||||
ctrdutil "github.com/containerd/containerd/pkg/cri/util"
|
||||
"github.com/containerd/containerd/protobuf"
|
||||
@ -98,7 +97,7 @@ func (c *Controller) stopSandboxContainer(ctx context.Context, sandbox sandboxst
|
||||
ExitStatus: exitStatus,
|
||||
ExitedAt: protobuf.ToTimestamp(exitedAt),
|
||||
}
|
||||
logrus.WithError(err).Errorf("Failed to wait sandbox exit %+v", e)
|
||||
log.G(ctx).WithError(err).Errorf("Failed to wait sandbox exit %+v", e)
|
||||
// TODO: how to backoff
|
||||
c.cri.BackOffEvent(id, e)
|
||||
}
|
||||
|
@ -36,7 +36,6 @@ import (
|
||||
ctrdutil "github.com/containerd/containerd/pkg/cri/util"
|
||||
"github.com/containerd/containerd/protobuf"
|
||||
"github.com/containerd/typeurl/v2"
|
||||
"github.com/sirupsen/logrus"
|
||||
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
|
||||
"k8s.io/utils/clock"
|
||||
)
|
||||
@ -264,18 +263,18 @@ func (em *eventMonitor) start() <-chan error {
|
||||
break
|
||||
}
|
||||
if em.backOff.isInBackOff(id) {
|
||||
logrus.Infof("Events for %q is in backoff, enqueue event %+v", id, evt)
|
||||
log.L.Infof("Events for %q is in backoff, enqueue event %+v", id, evt)
|
||||
em.backOff.enBackOff(id, evt)
|
||||
break
|
||||
}
|
||||
if err := em.handleEvent(evt); err != nil {
|
||||
logrus.WithError(err).Errorf("Failed to handle event %+v for %s", evt, id)
|
||||
log.L.WithError(err).Errorf("Failed to handle event %+v for %s", evt, id)
|
||||
em.backOff.enBackOff(id, evt)
|
||||
}
|
||||
case err := <-em.errCh:
|
||||
// Close errCh in defer directly if there is no error.
|
||||
if err != nil {
|
||||
logrus.WithError(err).Error("Failed to handle event stream")
|
||||
log.L.WithError(err).Error("Failed to handle event stream")
|
||||
errCh <- err
|
||||
}
|
||||
return
|
||||
@ -285,7 +284,7 @@ func (em *eventMonitor) start() <-chan error {
|
||||
queue := em.backOff.deBackOff(id)
|
||||
for i, evt := range queue.events {
|
||||
if err := em.handleEvent(evt); err != nil {
|
||||
logrus.WithError(err).Errorf("Failed to handle backOff event %+v for %s", evt, id)
|
||||
log.L.WithError(err).Errorf("Failed to handle backOff event %+v for %s", evt, id)
|
||||
em.backOff.reBackOff(id, queue.events[i:], queue.duration)
|
||||
break
|
||||
}
|
||||
@ -312,7 +311,7 @@ func (em *eventMonitor) handleEvent(any interface{}) error {
|
||||
|
||||
switch e := any.(type) {
|
||||
case *eventtypes.TaskExit:
|
||||
logrus.Infof("TaskExit event %+v", e)
|
||||
log.G(ctx).Infof("TaskExit event %+v", e)
|
||||
// Use ID instead of ContainerID to rule out TaskExit event for exec.
|
||||
cntr, err := em.c.containerStore.Get(e.ID)
|
||||
if err == nil {
|
||||
@ -334,7 +333,7 @@ func (em *eventMonitor) handleEvent(any interface{}) error {
|
||||
}
|
||||
return nil
|
||||
case *eventtypes.TaskOOM:
|
||||
logrus.Infof("TaskOOM event %+v", e)
|
||||
log.G(ctx).Infof("TaskOOM event %+v", e)
|
||||
// For TaskOOM, we only care which container it belongs to.
|
||||
cntr, err := em.c.containerStore.Get(e.ContainerID)
|
||||
if err != nil {
|
||||
@ -351,13 +350,13 @@ func (em *eventMonitor) handleEvent(any interface{}) error {
|
||||
return fmt.Errorf("failed to update container status for TaskOOM event: %w", err)
|
||||
}
|
||||
case *eventtypes.ImageCreate:
|
||||
logrus.Infof("ImageCreate event %+v", e)
|
||||
log.G(ctx).Infof("ImageCreate event %+v", e)
|
||||
return em.c.updateImage(ctx, e.Name)
|
||||
case *eventtypes.ImageUpdate:
|
||||
logrus.Infof("ImageUpdate event %+v", e)
|
||||
log.G(ctx).Infof("ImageUpdate event %+v", e)
|
||||
return em.c.updateImage(ctx, e.Name)
|
||||
case *eventtypes.ImageDelete:
|
||||
logrus.Infof("ImageDelete event %+v", e)
|
||||
log.G(ctx).Infof("ImageDelete event %+v", e)
|
||||
return em.c.updateImage(ctx, e.Name)
|
||||
}
|
||||
|
||||
@ -436,7 +435,7 @@ func handleContainerExit(ctx context.Context, e *eventtypes.TaskExit, cntr conta
|
||||
return fmt.Errorf("failed to cleanup container %s in task-service: %w", cntr.Container.ID(), err)
|
||||
}
|
||||
}
|
||||
logrus.Infof("Ensure that container %s in task-service has been cleanup successfully", cntr.Container.ID())
|
||||
log.G(ctx).Infof("Ensure that container %s in task-service has been cleanup successfully", cntr.Container.ID())
|
||||
}
|
||||
|
||||
err = cntr.Status.UpdateSync(func(status containerstore.Status) (containerstore.Status, error) {
|
||||
@ -449,7 +448,7 @@ func handleContainerExit(ctx context.Context, e *eventtypes.TaskExit, cntr conta
|
||||
// Unknown state can only transit to EXITED state, so we need
|
||||
// to handle unknown state here.
|
||||
if status.Unknown {
|
||||
logrus.Debugf("Container %q transited from UNKNOWN to EXITED", cntr.ID)
|
||||
log.G(ctx).Debugf("Container %q transited from UNKNOWN to EXITED", cntr.ID)
|
||||
status.Unknown = false
|
||||
}
|
||||
return status, nil
|
||||
@ -522,7 +521,7 @@ func handleSandboxExit(ctx context.Context, e *eventtypes.TaskExit, sb sandboxst
|
||||
return fmt.Errorf("failed to cleanup sandbox %s in task-service: %w", sb.Container.ID(), err)
|
||||
}
|
||||
}
|
||||
logrus.Infof("Ensure that sandbox %s in task-service has been cleanup successfully", sb.Container.ID())
|
||||
log.G(ctx).Infof("Ensure that sandbox %s in task-service has been cleanup successfully", sb.Container.ID())
|
||||
}
|
||||
err = sb.Status.Update(func(status sandboxstore.Status) (sandboxstore.Status, error) {
|
||||
status.State = sandboxstore.StateNotReady
|
||||
|
@ -41,7 +41,6 @@ import (
|
||||
runcoptions "github.com/containerd/containerd/runtime/v2/runc/options"
|
||||
"github.com/containerd/typeurl/v2"
|
||||
runtimespec "github.com/opencontainers/runtime-spec/specs-go"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
||||
runhcsoptions "github.com/Microsoft/hcsshim/cmd/containerd-shim-runhcs-v1/options"
|
||||
imagedigest "github.com/opencontainers/go-digest"
|
||||
@ -519,7 +518,7 @@ func (c *criService) generateAndSendContainerEvent(ctx context.Context, containe
|
||||
}
|
||||
containerStatuses, err := c.getContainerStatuses(ctx, sandboxID)
|
||||
if err != nil {
|
||||
logrus.Errorf("Failed to get container statuses for container event for sandboxID %q: %v", sandboxID, err)
|
||||
log.G(ctx).Errorf("Failed to get container statuses for container event for sandboxID %q: %v", sandboxID, err)
|
||||
}
|
||||
|
||||
event := runtime.ContainerEventResponse{
|
||||
@ -535,7 +534,7 @@ func (c *criService) generateAndSendContainerEvent(ctx context.Context, containe
|
||||
case c.containerEventsChan <- event:
|
||||
default:
|
||||
containerEventsDroppedCount.Inc()
|
||||
logrus.Debugf("containerEventsChan is full, discarding event %+v", event)
|
||||
log.G(ctx).Debugf("containerEventsChan is full, discarding event %+v", event)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,6 @@ import (
|
||||
"github.com/containerd/containerd/pkg/kmutex"
|
||||
"github.com/containerd/containerd/plugin"
|
||||
cni "github.com/containerd/go-cni"
|
||||
"github.com/sirupsen/logrus"
|
||||
"google.golang.org/grpc"
|
||||
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
|
||||
|
||||
@ -304,10 +303,10 @@ func (c *criService) Run(ready func()) error {
|
||||
// Close stops the CRI service.
|
||||
// TODO(random-liu): Make close synchronous.
|
||||
func (c *criService) Close() error {
|
||||
logrus.Info("Stop CRI service")
|
||||
log.L.Info("Stop CRI service")
|
||||
for name, h := range c.cniNetConfMonitor {
|
||||
if err := h.stop(); err != nil {
|
||||
logrus.WithError(err).Errorf("failed to stop cni network conf monitor for %s", name)
|
||||
log.L.WithError(err).Errorf("failed to stop cni network conf monitor for %s", name)
|
||||
}
|
||||
}
|
||||
c.eventMonitor.stop()
|
||||
|
@ -23,7 +23,7 @@ import (
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/containerd/containerd/log"
|
||||
)
|
||||
|
||||
// SourceDateEpochEnv is the SOURCE_DATE_EPOCH env var.
|
||||
@ -49,7 +49,7 @@ func SourceDateEpoch() (*time.Time, error) {
|
||||
func SourceDateEpochOrNow() time.Time {
|
||||
epoch, err := SourceDateEpoch()
|
||||
if err != nil {
|
||||
logrus.WithError(err).Warnf("Invalid %s", SourceDateEpochEnv)
|
||||
log.L.WithError(err).Warnf("Invalid %s", SourceDateEpochEnv)
|
||||
}
|
||||
if epoch != nil {
|
||||
return *epoch
|
||||
|
@ -25,7 +25,6 @@ import (
|
||||
"github.com/containerd/containerd/log"
|
||||
"github.com/containerd/containerd/namespaces"
|
||||
nri "github.com/containerd/nri/pkg/adaptation"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// Domain implements the functions the generic NRI interface needs to
|
||||
@ -57,10 +56,10 @@ type Domain interface {
|
||||
func RegisterDomain(d Domain) {
|
||||
err := domains.add(d)
|
||||
if err != nil {
|
||||
logrus.WithError(err).Fatalf("Failed to register namespace %q with NRI", d.GetName())
|
||||
log.L.WithError(err).Fatalf("Failed to register namespace %q with NRI", d.GetName())
|
||||
}
|
||||
|
||||
logrus.Infof("Registered namespace %q with NRI", d.GetName())
|
||||
log.L.Infof("Registered namespace %q with NRI", d.GetName())
|
||||
}
|
||||
|
||||
type domainTable struct {
|
||||
|
@ -23,7 +23,6 @@ import (
|
||||
"sync"
|
||||
|
||||
"github.com/containerd/containerd/log"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/containerd/containerd/version"
|
||||
nri "github.com/containerd/nri/pkg/adaptation"
|
||||
@ -110,7 +109,7 @@ func New(cfg *Config) (API, error) {
|
||||
}
|
||||
|
||||
if cfg.Disable {
|
||||
logrus.Info("NRI interface is disabled by configuration.")
|
||||
log.L.Info("NRI interface is disabled by configuration.")
|
||||
return l, nil
|
||||
}
|
||||
|
||||
@ -132,7 +131,7 @@ func New(cfg *Config) (API, error) {
|
||||
|
||||
l.state = make(map[string]State)
|
||||
|
||||
logrus.Info("created NRI interface")
|
||||
log.L.Info("created NRI interface")
|
||||
|
||||
return l, nil
|
||||
}
|
||||
|
@ -25,10 +25,10 @@ import (
|
||||
|
||||
"github.com/containerd/cgroups/v3/cgroup1"
|
||||
eventstypes "github.com/containerd/containerd/api/events"
|
||||
"github.com/containerd/containerd/log"
|
||||
"github.com/containerd/containerd/pkg/oom"
|
||||
"github.com/containerd/containerd/runtime"
|
||||
"github.com/containerd/containerd/runtime/v2/shim"
|
||||
"github.com/sirupsen/logrus"
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
@ -79,7 +79,7 @@ func (e *epoller) Run(ctx context.Context) {
|
||||
if err == unix.EINTR {
|
||||
continue
|
||||
}
|
||||
logrus.WithError(err).Error("cgroups: epoll wait")
|
||||
log.G(ctx).WithError(err).Error("cgroups: epoll wait")
|
||||
}
|
||||
for i := 0; i < n; i++ {
|
||||
e.process(ctx, uintptr(events[i].Fd))
|
||||
@ -130,7 +130,7 @@ func (e *epoller) process(ctx context.Context, fd uintptr) {
|
||||
if err := e.publisher.Publish(ctx, runtime.TaskOOMEventTopic, &eventstypes.TaskOOM{
|
||||
ContainerID: i.id,
|
||||
}); err != nil {
|
||||
logrus.WithError(err).Error("publish OOM event")
|
||||
log.G(ctx).WithError(err).Error("publish OOM event")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,10 +24,10 @@ import (
|
||||
|
||||
cgroupsv2 "github.com/containerd/cgroups/v3/cgroup2"
|
||||
eventstypes "github.com/containerd/containerd/api/events"
|
||||
"github.com/containerd/containerd/log"
|
||||
"github.com/containerd/containerd/pkg/oom"
|
||||
"github.com/containerd/containerd/runtime"
|
||||
"github.com/containerd/containerd/runtime/v2/shim"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// New returns an implementation that listens to OOM events
|
||||
@ -74,7 +74,7 @@ func (w *watcher) Run(ctx context.Context) {
|
||||
if err := w.publisher.Publish(ctx, runtime.TaskOOMEventTopic, &eventstypes.TaskOOM{
|
||||
ContainerID: i.id,
|
||||
}); err != nil {
|
||||
logrus.WithError(err).Error("publish OOM event")
|
||||
log.G(ctx).WithError(err).Error("publish OOM event")
|
||||
}
|
||||
}
|
||||
if i.ev.OOMKill > 0 {
|
||||
@ -106,7 +106,7 @@ func (w *watcher) Add(id string, cgx interface{}) error {
|
||||
i.err = err
|
||||
w.itemCh <- i
|
||||
// we no longer get any event/err when we got an err
|
||||
logrus.WithError(err).Warn("error from *cgroupsv2.Manager.EventChan")
|
||||
log.L.WithError(err).Warn("error from *cgroupsv2.Manager.EventChan")
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@ -23,9 +23,9 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/containerd/containerd/log"
|
||||
google_protobuf "github.com/containerd/containerd/protobuf/types"
|
||||
runc "github.com/containerd/go-runc"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
type initState interface {
|
||||
@ -341,7 +341,7 @@ func (s *pausedState) SetExited(status int) {
|
||||
s.p.setExited(status)
|
||||
|
||||
if err := s.p.runtime.Resume(context.Background(), s.p.id); err != nil {
|
||||
logrus.WithError(err).Error("resuming exited container from paused state")
|
||||
log.L.WithError(err).Error("resuming exited container from paused state")
|
||||
}
|
||||
|
||||
if err := s.transition("stopped"); err != nil {
|
||||
|
@ -26,7 +26,6 @@ import (
|
||||
"github.com/containerd/containerd/content/local"
|
||||
"github.com/containerd/containerd/log"
|
||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func FuzzConvertManifest(data []byte) int {
|
||||
@ -34,7 +33,7 @@ func FuzzConvertManifest(data []byte) int {
|
||||
|
||||
// Do not log the message below
|
||||
// level=warning msg="do nothing for media type: ..."
|
||||
log.G(ctx).Logger.SetLevel(logrus.PanicLevel)
|
||||
log.G(ctx).Logger.SetLevel(log.PanicLevel)
|
||||
|
||||
f := fuzz.NewConsumer(data)
|
||||
desc := ocispec.Descriptor{}
|
||||
|
@ -24,10 +24,10 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/containerd/containerd"
|
||||
"github.com/containerd/containerd/log"
|
||||
"github.com/containerd/containerd/namespaces"
|
||||
"github.com/containerd/containerd/plugin"
|
||||
"github.com/containerd/containerd/runtime/restart"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
type duration struct {
|
||||
@ -92,7 +92,7 @@ func (m *monitor) run(interval time.Duration) {
|
||||
}
|
||||
for {
|
||||
if err := m.reconcile(context.Background()); err != nil {
|
||||
logrus.WithError(err).Error("reconcile")
|
||||
log.L.WithError(err).Error("reconcile")
|
||||
}
|
||||
time.Sleep(interval)
|
||||
}
|
||||
@ -112,7 +112,7 @@ func (m *monitor) reconcile(ctx context.Context) error {
|
||||
ctx := namespaces.WithNamespace(ctx, name)
|
||||
changes, err := m.monitor(ctx)
|
||||
if err != nil {
|
||||
logrus.WithError(err).Error("monitor for changes")
|
||||
log.G(ctx).WithError(err).Error("monitor for changes")
|
||||
return
|
||||
}
|
||||
var wgChangesLoop sync.WaitGroup
|
||||
@ -122,7 +122,7 @@ func (m *monitor) reconcile(ctx context.Context) error {
|
||||
go func() {
|
||||
defer wgChangesLoop.Done()
|
||||
if err := c.apply(ctx, m.client); err != nil {
|
||||
logrus.WithError(err).Error("apply change")
|
||||
log.G(ctx).WithError(err).Error("apply change")
|
||||
}
|
||||
}()
|
||||
}
|
||||
@ -160,7 +160,7 @@ func (m *monitor) monitor(ctx context.Context) ([]change, error) {
|
||||
|
||||
// Task or Status return error, only desired to running
|
||||
if err != nil {
|
||||
logrus.WithError(err).Error("monitor")
|
||||
log.G(ctx).WithError(err).Error("monitor")
|
||||
if desiredStatus == containerd.Stopped {
|
||||
continue
|
||||
}
|
||||
@ -182,7 +182,7 @@ func (m *monitor) monitor(ctx context.Context) ([]change, error) {
|
||||
|
||||
restartCount, _ := strconv.Atoi(labels[restart.CountLabel])
|
||||
if labels["containerd.io/restart.logpath"] != "" {
|
||||
logrus.Warn(`Label "containerd.io/restart.logpath" is no longer supported since containerd v2.0. Use "containerd.io/restart.loguri" instead.`)
|
||||
log.G(ctx).Warn(`Label "containerd.io/restart.logpath" is no longer supported since containerd v2.0. Use "containerd.io/restart.loguri" instead.`)
|
||||
}
|
||||
changes = append(changes, &startChange{
|
||||
container: c,
|
||||
|
@ -39,7 +39,7 @@ import (
|
||||
"github.com/containerd/containerd"
|
||||
"github.com/containerd/containerd/cio"
|
||||
"github.com/containerd/containerd/containers"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/containerd/containerd/log"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -119,7 +119,7 @@ func (rp *Policy) MaximumRetryCount() int {
|
||||
func Reconcile(status containerd.Status, labels map[string]string) bool {
|
||||
rp, err := NewPolicy(labels[PolicyLabel])
|
||||
if err != nil {
|
||||
logrus.WithError(err).Error("policy reconcile")
|
||||
log.L.WithError(err).Error("policy reconcile")
|
||||
return false
|
||||
}
|
||||
switch rp.Name() {
|
||||
@ -128,7 +128,7 @@ func Reconcile(status containerd.Status, labels map[string]string) bool {
|
||||
case "on-failure":
|
||||
restartCount, err := strconv.Atoi(labels[CountLabel])
|
||||
if err != nil && labels[CountLabel] != "" {
|
||||
logrus.WithError(err).Error("policy reconcile")
|
||||
log.L.WithError(err).Error("policy reconcile")
|
||||
return false
|
||||
}
|
||||
if status.ExitStatus != 0 && (rp.maximumRetryCount == 0 || restartCount < rp.maximumRetryCount) {
|
||||
|
@ -167,7 +167,7 @@ func setLogger(ctx context.Context, id string) (context.Context, error) {
|
||||
FullTimestamp: true,
|
||||
})
|
||||
if debugFlag {
|
||||
l.Logger.SetLevel(logrus.DebugLevel)
|
||||
l.Logger.SetLevel(log.DebugLevel)
|
||||
}
|
||||
f, err := openLog(ctx, id)
|
||||
if err != nil {
|
||||
@ -235,13 +235,13 @@ func run(ctx context.Context, manager Manager, name string, config Config) error
|
||||
// Handle explicit actions
|
||||
switch action {
|
||||
case "delete":
|
||||
if debugFlag {
|
||||
logrus.SetLevel(logrus.DebugLevel)
|
||||
}
|
||||
logger := log.G(ctx).WithFields(log.Fields{
|
||||
"pid": os.Getpid(),
|
||||
"namespace": namespaceFlag,
|
||||
})
|
||||
if debugFlag {
|
||||
logger.Logger.SetLevel(log.DebugLevel)
|
||||
}
|
||||
go reap(ctx, logger, signals)
|
||||
ss, err := manager.Stop(ctx, id)
|
||||
if err != nil {
|
||||
@ -350,7 +350,7 @@ func run(ctx context.Context, manager Manager, name string, config Config) error
|
||||
}
|
||||
|
||||
if src, ok := instance.(TTRPCService); ok {
|
||||
logrus.WithField("id", id).Debug("registering ttrpc service")
|
||||
log.G(ctx).WithField("id", id).Debug("registering ttrpc service")
|
||||
ttrpcServices = append(ttrpcServices, src)
|
||||
|
||||
}
|
||||
@ -432,7 +432,7 @@ func serve(ctx context.Context, server *ttrpc.Server, signals chan os.Signal, sh
|
||||
return reap(ctx, logger, signals)
|
||||
}
|
||||
|
||||
func dumpStacks(logger *logrus.Entry) {
|
||||
func dumpStacks(logger *log.Entry) {
|
||||
var (
|
||||
buf []byte
|
||||
stackSize int
|
||||
|
@ -27,6 +27,7 @@ import (
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"github.com/containerd/containerd/log"
|
||||
"github.com/containerd/containerd/sys/reaper"
|
||||
"github.com/containerd/fifo"
|
||||
"github.com/sirupsen/logrus"
|
||||
@ -66,7 +67,7 @@ func serveListener(path string) (net.Listener, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
logrus.WithField("socket", path).Debug("serving api on socket")
|
||||
log.L.WithField("socket", path).Debug("serving api on socket")
|
||||
return l, nil
|
||||
}
|
||||
|
||||
|
@ -30,9 +30,9 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/containerd/continuity/fs/fstest"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/containerd/containerd/log"
|
||||
"github.com/containerd/containerd/mount"
|
||||
"github.com/containerd/containerd/snapshots"
|
||||
"github.com/containerd/containerd/snapshots/devmapper"
|
||||
@ -54,7 +54,9 @@ func init() {
|
||||
flag.StringVar(&nativeRootPath, "native.rootPath", "", "Root dir for native snapshotter")
|
||||
|
||||
// Avoid mixing benchmark output and INFO messages
|
||||
logrus.SetLevel(logrus.ErrorLevel)
|
||||
if err := log.SetLevel("error"); err != nil {
|
||||
panic(fmt.Sprintf("failed to set up log level: %v", err))
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkNative(b *testing.B) {
|
||||
|
@ -27,9 +27,9 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/containerd/continuity/fs/fstest"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/containerd/containerd/log"
|
||||
"github.com/containerd/containerd/mount"
|
||||
"github.com/containerd/containerd/namespaces"
|
||||
"github.com/containerd/containerd/pkg/testutil"
|
||||
@ -41,7 +41,7 @@ import (
|
||||
func TestSnapshotterSuite(t *testing.T) {
|
||||
testutil.RequiresRoot(t)
|
||||
|
||||
logrus.SetLevel(logrus.DebugLevel)
|
||||
assert.NoError(t, log.SetLevel("debug"))
|
||||
|
||||
snapshotterFn := func(ctx context.Context, root string) (snapshots.Snapshotter, func() error, error) {
|
||||
poolName := fmt.Sprintf("containerd-snapshotter-suite-pool-%d", time.Now().Nanosecond())
|
||||
@ -138,7 +138,7 @@ func TestMkfsXfsNonDefault(t *testing.T) {
|
||||
func TestMultipleXfsMounts(t *testing.T) {
|
||||
testutil.RequiresRoot(t)
|
||||
|
||||
logrus.SetLevel(logrus.DebugLevel)
|
||||
assert.NoError(t, log.SetLevel("debug"))
|
||||
|
||||
ctx := context.Background()
|
||||
ctx = namespaces.WithNamespace(ctx, "testsuite")
|
||||
|
@ -32,7 +32,6 @@ import (
|
||||
"github.com/containerd/containerd/snapshots/overlay/overlayutils"
|
||||
"github.com/containerd/containerd/snapshots/storage"
|
||||
"github.com/containerd/continuity/fs"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// upperdirKey is a key of an optional label to each snapshot.
|
||||
@ -137,7 +136,7 @@ func NewSnapshotter(root string, opts ...Opt) (snapshots.Snapshotter, error) {
|
||||
// figure out whether "userxattr" option is recognized by the kernel && needed
|
||||
userxattr, err := overlayutils.NeedsUserXAttr(root)
|
||||
if err != nil {
|
||||
logrus.WithError(err).Warnf("cannot detect whether \"userxattr\" option needs to be used, assuming to be %v", userxattr)
|
||||
log.L.WithError(err).Warnf("cannot detect whether \"userxattr\" option needs to be used, assuming to be %v", userxattr)
|
||||
}
|
||||
if userxattr {
|
||||
config.mountOptions = append(config.mountOptions, "userxattr")
|
||||
|
Loading…
Reference in New Issue
Block a user