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