diff --git a/.golangci.yml b/.golangci.yml index 8cb4b6f5cf..17cf1b6a2a 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -11,6 +11,12 @@ run: - pkg/remote/remotes linters-settings: + depguard: + rules: + main: + deny: + - pkg: "github.com/containerd/containerd/log" + desc: The containerd log package was migrated to a separate module. Use github.com/containerd/log instead. # govet: # check-shadowing: true # enable: @@ -34,6 +40,7 @@ linters-settings: linters: enable: + - depguard # Checks for imports that shouldn't be used. - staticcheck - unconvert - gofmt diff --git a/cmd/containerd-nydus-grpc/main.go b/cmd/containerd-nydus-grpc/main.go index 535a1637a9..203962d595 100644 --- a/cmd/containerd-nydus-grpc/main.go +++ b/cmd/containerd-nydus-grpc/main.go @@ -11,7 +11,7 @@ import ( "fmt" "os" - "github.com/containerd/containerd/log" + "github.com/containerd/log" "github.com/pkg/errors" "github.com/urfave/cli/v2" diff --git a/cmd/containerd-nydus-grpc/snapshotter.go b/cmd/containerd-nydus-grpc/snapshotter.go index 9d90b804a7..cb4dcd1b87 100644 --- a/cmd/containerd-nydus-grpc/snapshotter.go +++ b/cmd/containerd-nydus-grpc/snapshotter.go @@ -22,8 +22,8 @@ import ( api "github.com/containerd/containerd/api/services/snapshots/v1" "github.com/containerd/containerd/contrib/snapshotservice" - "github.com/containerd/containerd/log" "github.com/containerd/containerd/snapshots" + "github.com/containerd/log" "google.golang.org/grpc" ) diff --git a/cmd/optimizer-nri-plugin/main.go b/cmd/optimizer-nri-plugin/main.go index ed812ee964..b3e6646da9 100644 --- a/cmd/optimizer-nri-plugin/main.go +++ b/cmd/optimizer-nri-plugin/main.go @@ -16,8 +16,8 @@ import ( "strings" "time" + "github.com/containerd/log" "github.com/pkg/errors" - "github.com/sirupsen/logrus" "github.com/urfave/cli/v2" "github.com/containerd/containerd/reference/docker" @@ -122,7 +122,6 @@ type plugin struct { var ( cfg PluginConfig - log *logrus.Logger logWriter *syslog.Writer globalFanotifyServer = make(map[string]*fanotify.Server) @@ -135,8 +134,8 @@ const ( imageNameLabel = "io.kubernetes.cri.image-name" ) -func (p *plugin) Configure(_ context.Context, config, runtime, version string) (stub.EventMask, error) { - log.Infof("got configuration data: %q from runtime %s %s", config, runtime, version) +func (p *plugin) Configure(ctx context.Context, config, runtime, version string) (stub.EventMask, error) { + log.G(ctx).Infof("got configuration data: %q from runtime %s %s", config, runtime, version) if config == "" { return p.mask, nil } @@ -154,7 +153,7 @@ func (p *plugin) Configure(_ context.Context, config, runtime, version string) ( return 0, errors.Wrap(err, "parse events in configuration") } - log.Infof("configuration: %#v", cfg) + log.G(ctx).Infof("configuration: %#v", cfg) return p.mask, nil } @@ -240,13 +239,13 @@ func main() { cfg = flags.Args.Config - log = logrus.StandardLogger() - log.SetFormatter(&logrus.TextFormatter{ - PadLevelText: true, - }) + // FIXME(thaJeztah): ucontainerd's log does not set "PadLevelText: true" + _ = log.SetFormat(log.TextFormat) + ctx := log.WithLogger(context.Background(), log.L) + logWriter, err = syslog.New(syslog.LOG_INFO, "optimizer-nri-plugin") if err == nil { - log.SetOutput(io.MultiWriter(os.Stdout, logWriter)) + log.G(ctx).Logger.SetOutput(io.MultiWriter(os.Stdout, logWriter)) } if flags.Args.PluginName != "" { @@ -259,17 +258,17 @@ func main() { p := &plugin{} if p.mask, err = api.ParseEventMask(flags.Args.PluginEvents); err != nil { - log.Fatalf("failed to parse events: %v", err) + log.G(ctx).Fatalf("failed to parse events: %v", err) } cfg.Events = strings.Split(flags.Args.PluginEvents, ",") if p.stub, err = stub.New(p, append(opts, stub.WithOnClose(p.onClose))...); err != nil { - log.Fatalf("failed to create plugin stub: %v", err) + log.G(ctx).Fatalf("failed to create plugin stub: %v", err) } err = p.stub.Run(context.Background()) if err != nil { - log.Errorf("plugin exited with error %v", err) + log.G(ctx).Errorf("plugin exited with error %v", err) os.Exit(1) } @@ -278,9 +277,9 @@ func main() { } if err := app.Run(os.Args); err != nil { if errdefs.IsConnectionClosed(err) { - log.Info("optimizer NRI plugin exited") + log.L.Info("optimizer NRI plugin exited") } else { - log.WithError(err).Fatal("failed to start optimizer NRI plugin") + log.L.WithError(err).Fatal("failed to start optimizer NRI plugin") } } } diff --git a/cmd/prefetchfiles-nri-plugin/main.go b/cmd/prefetchfiles-nri-plugin/main.go index 87d33e06e9..de9fbe5575 100644 --- a/cmd/prefetchfiles-nri-plugin/main.go +++ b/cmd/prefetchfiles-nri-plugin/main.go @@ -17,11 +17,11 @@ import ( "path/filepath" "strings" + "github.com/containerd/log" "github.com/containerd/nri/pkg/api" "github.com/containerd/nri/pkg/stub" "github.com/pelletier/go-toml" "github.com/pkg/errors" - "github.com/sirupsen/logrus" "github.com/urfave/cli/v2" "github.com/containerd/nydus-snapshotter/pkg/errdefs" @@ -83,7 +83,6 @@ type plugin struct { var ( globalSocket string - log *logrus.Logger logWriter *syslog.Writer _ = stub.RunPodInterface(&plugin{}) @@ -117,7 +116,7 @@ func sendDataOverHTTP(data string, endpoint, sock string) error { return nil } -func (p *plugin) RunPodSandbox(_ context.Context, pod *api.PodSandbox) error { +func (p *plugin) RunPodSandbox(ctx context.Context, pod *api.PodSandbox) error { prefetchList, ok := pod.Annotations[nydusPrefetchAnnotation] if !ok { return nil @@ -125,7 +124,7 @@ func (p *plugin) RunPodSandbox(_ context.Context, pod *api.PodSandbox) error { err := sendDataOverHTTP(prefetchList, endpointPrefetch, globalSocket) if err != nil { - log.Errorf("failed to send data: %v", err) + log.G(ctx).Errorf("failed to send data: %v", err) return err } @@ -133,7 +132,6 @@ func (p *plugin) RunPodSandbox(_ context.Context, pod *api.PodSandbox) error { } func main() { - flags := NewPluginFlags() app := &cli.App{ @@ -148,7 +146,9 @@ func main() { err error ) - log = logrus.StandardLogger() + // FIXME(thaJeztah): ucontainerd's log does not set "PadLevelText: true" + _ = log.SetFormat(log.TextFormat) + ctx := log.WithLogger(context.Background(), log.L) configFileName := "prefetchConfig.toml" configDir := defaultPrefetchConfigDir @@ -156,7 +156,7 @@ func main() { config, err := toml.LoadFile(configFilePath) if err != nil { - log.Warnf("failed to read config file: %v", err) + log.G(ctx).Warnf("failed to read config file: %v", err) } configSocketAddrRaw := config.Get("file_prefetch.socket_address") @@ -164,19 +164,15 @@ func main() { if configSocketAddr, ok := configSocketAddrRaw.(string); ok { globalSocket = configSocketAddr } else { - log.Warnf("failed to read config: 'file_prefetch.socket_address' is not a string") + log.G(ctx).Warnf("failed to read config: 'file_prefetch.socket_address' is not a string") } } else { globalSocket = flags.Args.SocketAddress } - log.SetFormatter(&logrus.TextFormatter{ - PadLevelText: true, - }) logWriter, err = syslog.New(syslog.LOG_INFO, "prefetch-nri-plugin") - if err == nil { - log.SetOutput(io.MultiWriter(os.Stdout, logWriter)) + log.G(ctx).Logger.SetOutput(io.MultiWriter(os.Stdout, logWriter)) } if flags.Args.PluginName != "" { @@ -189,11 +185,11 @@ func main() { p := &plugin{} if p.mask, err = api.ParseEventMask(defaultEvents); err != nil { - log.Fatalf("failed to parse events: %v", err) + log.G(ctx).Fatalf("failed to parse events: %v", err) } if p.stub, err = stub.New(p, opts...); err != nil { - log.Fatalf("failed to create plugin stub: %v", err) + log.G(ctx).Fatalf("failed to create plugin stub: %v", err) } err = p.stub.Run(context.Background()) @@ -204,11 +200,10 @@ func main() { }, } if err := app.Run(os.Args); err != nil { - if errdefs.IsConnectionClosed(err) { - log.Info("prefetch NRI plugin exited") + log.L.Info("prefetch NRI plugin exited") } else { - log.WithError(err).Fatal("failed to start prefetch NRI plugin") + log.L.WithError(err).Fatal("failed to start prefetch NRI plugin") } } } diff --git a/config/daemonconfig/fscache.go b/config/daemonconfig/fscache.go index cc7bcde081..7c9911cb62 100644 --- a/config/daemonconfig/fscache.go +++ b/config/daemonconfig/fscache.go @@ -11,7 +11,7 @@ import ( "os" "path" - "github.com/containerd/containerd/log" + "github.com/containerd/log" "github.com/containerd/nydus-snapshotter/pkg/auth" "github.com/containerd/nydus-snapshotter/pkg/utils/erofs" diff --git a/config/daemonconfig/mirrors.go b/config/daemonconfig/mirrors.go index 116b0e2caa..ed32a95233 100644 --- a/config/daemonconfig/mirrors.go +++ b/config/daemonconfig/mirrors.go @@ -15,7 +15,7 @@ import ( "sort" "strings" - "github.com/containerd/containerd/log" + "github.com/containerd/log" "github.com/pelletier/go-toml" "github.com/pkg/errors" ) diff --git a/config/global.go b/config/global.go index 3c1906073a..61bee2d2cb 100644 --- a/config/global.go +++ b/config/global.go @@ -14,7 +14,7 @@ import ( "path/filepath" "time" - "github.com/containerd/containerd/log" + "github.com/containerd/log" "github.com/pkg/errors" "github.com/containerd/nydus-snapshotter/internal/logging" diff --git a/go.mod b/go.mod index ec40f9ed2e..0f78f78f20 100644 --- a/go.mod +++ b/go.mod @@ -15,6 +15,7 @@ require ( github.com/containerd/containerd v1.7.7 github.com/containerd/continuity v0.4.2 github.com/containerd/fifo v1.1.0 + github.com/containerd/log v0.1.0 github.com/containerd/nri v0.4.0 github.com/containerd/stargz-snapshotter v0.14.3 github.com/containerd/stargz-snapshotter/estargz v0.14.3 @@ -77,7 +78,6 @@ require ( github.com/beorn7/perks v1.0.1 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/cilium/ebpf v0.9.1 // indirect - github.com/containerd/log v0.1.0 // indirect github.com/containerd/ttrpc v1.2.2 // indirect github.com/containerd/typeurl/v2 v2.1.1 // indirect github.com/coreos/go-systemd/v22 v22.5.0 // indirect diff --git a/internal/logging/setup.go b/internal/logging/setup.go index 62204bcc6f..21b8297d2c 100644 --- a/internal/logging/setup.go +++ b/internal/logging/setup.go @@ -12,7 +12,7 @@ import ( "os" "path/filepath" - "github.com/containerd/containerd/log" + "github.com/containerd/log" "github.com/pkg/errors" "github.com/sirupsen/logrus" lumberjack "gopkg.in/natefinch/lumberjack.v2" diff --git a/internal/logging/setup_test.go b/internal/logging/setup_test.go index f6bb724908..47af47c401 100644 --- a/internal/logging/setup_test.go +++ b/internal/logging/setup_test.go @@ -13,7 +13,7 @@ import ( "testing" "time" - "github.com/containerd/containerd/log" + "github.com/containerd/log" "github.com/sirupsen/logrus" "gotest.tools/assert" ) diff --git a/pkg/auth/image_proxy.go b/pkg/auth/image_proxy.go index c7b0a56b81..eac12b06b1 100644 --- a/pkg/auth/image_proxy.go +++ b/pkg/auth/image_proxy.go @@ -12,11 +12,11 @@ import ( "time" "github.com/containerd/containerd/defaults" - "github.com/containerd/containerd/log" "github.com/containerd/containerd/pkg/dialer" "github.com/containerd/containerd/reference" distribution "github.com/containerd/containerd/reference/docker" runtime_alpha "github.com/containerd/containerd/third_party/k8s.io/cri-api/pkg/apis/runtime/v1alpha2" + "github.com/containerd/log" "github.com/containerd/stargz-snapshotter/service/keychain/cri" "github.com/containerd/stargz-snapshotter/service/keychain/crialpha" "github.com/containerd/stargz-snapshotter/service/resolver" diff --git a/pkg/cache/manager.go b/pkg/cache/manager.go index 7dc70a380e..ab9e7640fb 100644 --- a/pkg/cache/manager.go +++ b/pkg/cache/manager.go @@ -14,9 +14,9 @@ import ( "github.com/pkg/errors" - "github.com/containerd/containerd/log" "github.com/containerd/containerd/snapshots" "github.com/containerd/continuity/fs" + "github.com/containerd/log" "github.com/containerd/nydus-snapshotter/pkg/store" ) diff --git a/pkg/cgroup/manager.go b/pkg/cgroup/manager.go index 0ca9dd0b63..f0010808d0 100644 --- a/pkg/cgroup/manager.go +++ b/pkg/cgroup/manager.go @@ -7,7 +7,7 @@ package cgroup import ( - "github.com/containerd/containerd/log" + "github.com/containerd/log" ) type Manager struct { diff --git a/pkg/cgroup/v1/v1.go b/pkg/cgroup/v1/v1.go index 4dab8498b5..b737a8a1b6 100644 --- a/pkg/cgroup/v1/v1.go +++ b/pkg/cgroup/v1/v1.go @@ -8,7 +8,7 @@ package v1 import ( "github.com/containerd/cgroups/v3/cgroup1" - "github.com/containerd/containerd/log" + "github.com/containerd/log" "github.com/opencontainers/runtime-spec/specs-go" "github.com/pkg/errors" ) diff --git a/pkg/cgroup/v2/v2.go b/pkg/cgroup/v2/v2.go index 719295cc90..0102b895dd 100644 --- a/pkg/cgroup/v2/v2.go +++ b/pkg/cgroup/v2/v2.go @@ -14,7 +14,7 @@ import ( "strings" "github.com/containerd/cgroups/v3/cgroup2" - "github.com/containerd/containerd/log" + "github.com/containerd/log" "golang.org/x/exp/slices" ) diff --git a/pkg/daemon/client.go b/pkg/daemon/client.go index 54feaa2f2a..a1b13bafbc 100644 --- a/pkg/daemon/client.go +++ b/pkg/daemon/client.go @@ -22,7 +22,7 @@ import ( "github.com/pkg/errors" - "github.com/containerd/containerd/log" + "github.com/containerd/log" "github.com/containerd/nydus-snapshotter/pkg/daemon/types" "github.com/containerd/nydus-snapshotter/pkg/metrics/tool" "github.com/containerd/nydus-snapshotter/pkg/utils/retry" diff --git a/pkg/daemon/daemon.go b/pkg/daemon/daemon.go index 8bd955cdcc..2c3a68603b 100644 --- a/pkg/daemon/daemon.go +++ b/pkg/daemon/daemon.go @@ -18,7 +18,7 @@ import ( "github.com/pkg/errors" - "github.com/containerd/containerd/log" + "github.com/containerd/log" "github.com/containerd/nydus-snapshotter/config" "github.com/containerd/nydus-snapshotter/config/daemonconfig" diff --git a/pkg/filesystem/fs.go b/pkg/filesystem/fs.go index 60b093dc6b..0bb9d8012c 100644 --- a/pkg/filesystem/fs.go +++ b/pkg/filesystem/fs.go @@ -21,9 +21,9 @@ import ( "github.com/pkg/errors" "golang.org/x/sync/errgroup" - "github.com/containerd/containerd/log" "github.com/containerd/containerd/snapshots" "github.com/containerd/containerd/snapshots/storage" + "github.com/containerd/log" "github.com/containerd/nydus-snapshotter/config" "github.com/containerd/nydus-snapshotter/config/daemonconfig" diff --git a/pkg/filesystem/stargz_adaptor.go b/pkg/filesystem/stargz_adaptor.go index 2948a62ae9..69eaf304a4 100644 --- a/pkg/filesystem/stargz_adaptor.go +++ b/pkg/filesystem/stargz_adaptor.go @@ -17,8 +17,8 @@ import ( "time" "github.com/KarpelesLab/reflink" - "github.com/containerd/containerd/log" "github.com/containerd/containerd/snapshots/storage" + "github.com/containerd/log" "github.com/containerd/nydus-snapshotter/config" "github.com/containerd/nydus-snapshotter/pkg/auth" "github.com/containerd/nydus-snapshotter/pkg/label" diff --git a/pkg/filesystem/tarfs_adaptor.go b/pkg/filesystem/tarfs_adaptor.go index 5d95ad51cb..ccc1231fb9 100755 --- a/pkg/filesystem/tarfs_adaptor.go +++ b/pkg/filesystem/tarfs_adaptor.go @@ -9,9 +9,9 @@ package filesystem import ( "context" - "github.com/containerd/containerd/log" snpkg "github.com/containerd/containerd/pkg/snapshotters" "github.com/containerd/containerd/snapshots/storage" + "github.com/containerd/log" "github.com/containerd/nydus-snapshotter/pkg/label" "github.com/opencontainers/go-digest" "github.com/pkg/errors" diff --git a/pkg/manager/daemon_adaptor.go b/pkg/manager/daemon_adaptor.go index e1335c1d6b..44c61fbea4 100644 --- a/pkg/manager/daemon_adaptor.go +++ b/pkg/manager/daemon_adaptor.go @@ -13,7 +13,7 @@ import ( "strings" "time" - "github.com/containerd/containerd/log" + "github.com/containerd/log" "github.com/pkg/errors" "github.com/containerd/nydus-snapshotter/config" diff --git a/pkg/manager/daemon_cache.go b/pkg/manager/daemon_cache.go index 8e42e603ee..bc4c027b71 100644 --- a/pkg/manager/daemon_cache.go +++ b/pkg/manager/daemon_cache.go @@ -10,7 +10,7 @@ package manager import ( "sync" - "github.com/containerd/containerd/log" + "github.com/containerd/log" "github.com/containerd/nydus-snapshotter/pkg/daemon" ) diff --git a/pkg/manager/daemon_event.go b/pkg/manager/daemon_event.go index 2eea237b00..e4b4454d33 100644 --- a/pkg/manager/daemon_event.go +++ b/pkg/manager/daemon_event.go @@ -10,7 +10,7 @@ package manager import ( "time" - "github.com/containerd/containerd/log" + "github.com/containerd/log" "github.com/containerd/nydus-snapshotter/config" "github.com/containerd/nydus-snapshotter/pkg/daemon" "github.com/containerd/nydus-snapshotter/pkg/daemon/types" diff --git a/pkg/manager/manager.go b/pkg/manager/manager.go index 27b6fad7d6..5e4cf88951 100644 --- a/pkg/manager/manager.go +++ b/pkg/manager/manager.go @@ -14,7 +14,7 @@ import ( "path/filepath" "sync" - "github.com/containerd/containerd/log" + "github.com/containerd/log" "github.com/pkg/errors" "github.com/containerd/nydus-snapshotter/config" diff --git a/pkg/manager/monitor.go b/pkg/manager/monitor.go index 1664aeb960..a14c5e9fa8 100644 --- a/pkg/manager/monitor.go +++ b/pkg/manager/monitor.go @@ -15,7 +15,7 @@ import ( "github.com/pkg/errors" "golang.org/x/sys/unix" - "github.com/containerd/containerd/log" + "github.com/containerd/log" "github.com/containerd/nydus-snapshotter/pkg/daemon/types" "github.com/containerd/nydus-snapshotter/pkg/errdefs" "github.com/containerd/nydus-snapshotter/pkg/metrics/collector" diff --git a/pkg/metrics/collector/daemon.go b/pkg/metrics/collector/daemon.go index ddf1a2f32d..196ea4b990 100644 --- a/pkg/metrics/collector/daemon.go +++ b/pkg/metrics/collector/daemon.go @@ -7,7 +7,7 @@ package collector import ( - "github.com/containerd/containerd/log" + "github.com/containerd/log" "github.com/containerd/nydus-snapshotter/pkg/daemon/types" "github.com/containerd/nydus-snapshotter/pkg/metrics/data" ) diff --git a/pkg/metrics/collector/fs.go b/pkg/metrics/collector/fs.go index da9172f264..9effabee8e 100644 --- a/pkg/metrics/collector/fs.go +++ b/pkg/metrics/collector/fs.go @@ -9,7 +9,7 @@ package collector import ( "time" - "github.com/containerd/containerd/log" + "github.com/containerd/log" "github.com/containerd/nydus-snapshotter/pkg/daemon/types" "github.com/containerd/nydus-snapshotter/pkg/metrics/data" mtypes "github.com/containerd/nydus-snapshotter/pkg/metrics/types" diff --git a/pkg/metrics/collector/snapshotter.go b/pkg/metrics/collector/snapshotter.go index 1e614286dc..d3e3333f6c 100644 --- a/pkg/metrics/collector/snapshotter.go +++ b/pkg/metrics/collector/snapshotter.go @@ -9,8 +9,8 @@ package collector import ( "context" - "github.com/containerd/containerd/log" "github.com/containerd/continuity/fs" + "github.com/containerd/log" "github.com/containerd/nydus-snapshotter/pkg/metrics/data" "github.com/containerd/nydus-snapshotter/pkg/metrics/tool" "github.com/prometheus/client_golang/prometheus" diff --git a/pkg/metrics/listener.go b/pkg/metrics/listener.go index 65c8a5ebd4..08451699b2 100644 --- a/pkg/metrics/listener.go +++ b/pkg/metrics/listener.go @@ -12,7 +12,7 @@ import ( "net" "net/http" - "github.com/containerd/containerd/log" + "github.com/containerd/log" "github.com/containerd/nydus-snapshotter/pkg/metrics/registry" "github.com/pkg/errors" "github.com/prometheus/client_golang/prometheus/promhttp" diff --git a/pkg/metrics/serve.go b/pkg/metrics/serve.go index 7c46c57b2e..34a2561a5c 100644 --- a/pkg/metrics/serve.go +++ b/pkg/metrics/serve.go @@ -14,7 +14,7 @@ import ( "github.com/pkg/errors" - "github.com/containerd/containerd/log" + "github.com/containerd/log" "github.com/containerd/nydus-snapshotter/config" "github.com/containerd/nydus-snapshotter/pkg/daemon/types" "github.com/containerd/nydus-snapshotter/pkg/manager" diff --git a/pkg/metrics/tool/common.go b/pkg/metrics/tool/common.go index af76cff5b0..66c3996bcc 100644 --- a/pkg/metrics/tool/common.go +++ b/pkg/metrics/tool/common.go @@ -13,7 +13,7 @@ import ( "strconv" "strings" - "github.com/containerd/containerd/log" + "github.com/containerd/log" ) const ( diff --git a/pkg/pprof/listener.go b/pkg/pprof/listener.go index 99bb38655f..c260b1acbc 100644 --- a/pkg/pprof/listener.go +++ b/pkg/pprof/listener.go @@ -11,7 +11,7 @@ import ( "net/http" "net/http/pprof" - "github.com/containerd/containerd/log" + "github.com/containerd/log" "github.com/pkg/errors" ) diff --git a/pkg/prefetch/prefetch.go b/pkg/prefetch/prefetch.go index 6f2d01cd3d..6f8ebda384 100644 --- a/pkg/prefetch/prefetch.go +++ b/pkg/prefetch/prefetch.go @@ -10,7 +10,7 @@ import ( "encoding/json" "sync" - "github.com/containerd/containerd/log" + "github.com/containerd/log" ) type prefetchInfo struct { diff --git a/pkg/referrer/manager.go b/pkg/referrer/manager.go index 1134457d99..b8f153659e 100644 --- a/pkg/referrer/manager.go +++ b/pkg/referrer/manager.go @@ -9,7 +9,7 @@ package referrer import ( "context" - "github.com/containerd/containerd/log" + "github.com/containerd/log" "github.com/containerd/nydus-snapshotter/pkg/auth" "github.com/golang/groupcache/lru" "github.com/opencontainers/go-digest" diff --git a/pkg/remote/remote.go b/pkg/remote/remote.go index cbcd0a08b7..ce287baa46 100644 --- a/pkg/remote/remote.go +++ b/pkg/remote/remote.go @@ -13,13 +13,12 @@ import ( "net/http" "strings" + "github.com/containerd/log" "github.com/containerd/nydus-snapshotter/pkg/auth" - "github.com/distribution/reference" - "github.com/pkg/errors" - "github.com/sirupsen/logrus" - "github.com/containerd/nydus-snapshotter/pkg/remote/remotes" "github.com/containerd/nydus-snapshotter/pkg/remote/remotes/docker" + "github.com/distribution/reference" + "github.com/pkg/errors" ) // IsErrHTTPResponseToHTTPSClient returns whether err is @@ -106,7 +105,7 @@ func (remote *Remote) RetryWithPlainHTTP(ref string, err error) bool { // If the error message includes the current registry host string, it // implies that we can retry the request with plain HTTP. if strings.Contains(err.Error(), fmt.Sprintf("/%s/", host)) { - logrus.WithError(err).Warningf("retrying with http for %s", host) + log.G(context.TODO()).WithError(err).Warningf("retrying with http for %s", host) remote.withPlainHTTP = true } } diff --git a/pkg/remote/remotes/docker/auth/fetch.go b/pkg/remote/remotes/docker/auth/fetch.go index 10ed2e62c9..996aba0c6e 100644 --- a/pkg/remote/remotes/docker/auth/fetch.go +++ b/pkg/remote/remotes/docker/auth/fetch.go @@ -26,8 +26,8 @@ import ( "strings" "time" - "github.com/containerd/containerd/log" "github.com/containerd/containerd/version" + "github.com/containerd/log" remoteserrors "github.com/containerd/nydus-snapshotter/pkg/remote/remotes/errors" ) diff --git a/pkg/remote/remotes/docker/authorizer.go b/pkg/remote/remotes/docker/authorizer.go index 1f7b696afd..3c8e300fca 100644 --- a/pkg/remote/remotes/docker/authorizer.go +++ b/pkg/remote/remotes/docker/authorizer.go @@ -26,7 +26,7 @@ import ( "sync" "github.com/containerd/containerd/errdefs" - "github.com/containerd/containerd/log" + "github.com/containerd/log" "github.com/containerd/nydus-snapshotter/pkg/remote/remotes/docker/auth" remoteerrors "github.com/containerd/nydus-snapshotter/pkg/remote/remotes/errors" ) diff --git a/pkg/remote/remotes/docker/config/hosts.go b/pkg/remote/remotes/docker/config/hosts.go index b127a438ad..22e7d1a53f 100644 --- a/pkg/remote/remotes/docker/config/hosts.go +++ b/pkg/remote/remotes/docker/config/hosts.go @@ -33,7 +33,7 @@ import ( "time" "github.com/containerd/containerd/errdefs" - "github.com/containerd/containerd/log" + "github.com/containerd/log" "github.com/containerd/nydus-snapshotter/pkg/remote/remotes/docker" "github.com/pelletier/go-toml" ) diff --git a/pkg/remote/remotes/docker/converter.go b/pkg/remote/remotes/docker/converter.go index 66864d7002..129dea8fc8 100644 --- a/pkg/remote/remotes/docker/converter.go +++ b/pkg/remote/remotes/docker/converter.go @@ -24,7 +24,7 @@ import ( "github.com/containerd/containerd/content" "github.com/containerd/containerd/images" - "github.com/containerd/containerd/log" + "github.com/containerd/log" "github.com/containerd/nydus-snapshotter/pkg/remote/remotes" digest "github.com/opencontainers/go-digest" ocispec "github.com/opencontainers/image-spec/specs-go/v1" diff --git a/pkg/remote/remotes/docker/converter_fuzz.go b/pkg/remote/remotes/docker/converter_fuzz.go index 9082053924..aa7cf4666f 100644 --- a/pkg/remote/remotes/docker/converter_fuzz.go +++ b/pkg/remote/remotes/docker/converter_fuzz.go @@ -24,7 +24,7 @@ import ( fuzz "github.com/AdaLogics/go-fuzz-headers" "github.com/containerd/containerd/content/local" - "github.com/containerd/containerd/log" + "github.com/containerd/log" ocispec "github.com/opencontainers/image-spec/specs-go/v1" "github.com/sirupsen/logrus" ) diff --git a/pkg/remote/remotes/docker/fetcher.go b/pkg/remote/remotes/docker/fetcher.go index bfe00172ac..21c0918c5e 100644 --- a/pkg/remote/remotes/docker/fetcher.go +++ b/pkg/remote/remotes/docker/fetcher.go @@ -28,7 +28,7 @@ import ( "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/images" - "github.com/containerd/containerd/log" + "github.com/containerd/log" digest "github.com/opencontainers/go-digest" ocispec "github.com/opencontainers/image-spec/specs-go/v1" ) diff --git a/pkg/remote/remotes/docker/handler.go b/pkg/remote/remotes/docker/handler.go index 27638ccc02..ccec490133 100644 --- a/pkg/remote/remotes/docker/handler.go +++ b/pkg/remote/remotes/docker/handler.go @@ -25,8 +25,8 @@ import ( "github.com/containerd/containerd/content" "github.com/containerd/containerd/images" "github.com/containerd/containerd/labels" - "github.com/containerd/containerd/log" "github.com/containerd/containerd/reference" + "github.com/containerd/log" ocispec "github.com/opencontainers/image-spec/specs-go/v1" ) diff --git a/pkg/remote/remotes/docker/httpreadseeker.go b/pkg/remote/remotes/docker/httpreadseeker.go index 9a827ef04c..7e7790d2b3 100644 --- a/pkg/remote/remotes/docker/httpreadseeker.go +++ b/pkg/remote/remotes/docker/httpreadseeker.go @@ -22,7 +22,7 @@ import ( "io" "github.com/containerd/containerd/errdefs" - "github.com/containerd/containerd/log" + "github.com/containerd/log" ) const maxRetry = 3 diff --git a/pkg/remote/remotes/docker/pusher.go b/pkg/remote/remotes/docker/pusher.go index 24b63c00cd..f82b99f6ec 100644 --- a/pkg/remote/remotes/docker/pusher.go +++ b/pkg/remote/remotes/docker/pusher.go @@ -30,7 +30,7 @@ import ( "github.com/containerd/containerd/content" "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/images" - "github.com/containerd/containerd/log" + "github.com/containerd/log" "github.com/containerd/nydus-snapshotter/pkg/remote/remotes" remoteserrors "github.com/containerd/nydus-snapshotter/pkg/remote/remotes/errors" digest "github.com/opencontainers/go-digest" diff --git a/pkg/remote/remotes/docker/referrers.go b/pkg/remote/remotes/docker/referrers.go index d240eb42a2..aa2eb201e8 100644 --- a/pkg/remote/remotes/docker/referrers.go +++ b/pkg/remote/remotes/docker/referrers.go @@ -24,7 +24,7 @@ import ( "strings" "github.com/containerd/containerd/errdefs" - "github.com/containerd/containerd/log" + "github.com/containerd/log" digest "github.com/opencontainers/go-digest" ocispec "github.com/opencontainers/image-spec/specs-go/v1" ) diff --git a/pkg/remote/remotes/docker/resolver.go b/pkg/remote/remotes/docker/resolver.go index 99c941bd67..9c380a35d0 100644 --- a/pkg/remote/remotes/docker/resolver.go +++ b/pkg/remote/remotes/docker/resolver.go @@ -29,10 +29,10 @@ import ( "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/images" - "github.com/containerd/containerd/log" "github.com/containerd/containerd/reference" "github.com/containerd/containerd/tracing" "github.com/containerd/containerd/version" + "github.com/containerd/log" "github.com/containerd/nydus-snapshotter/pkg/remote/remotes" "github.com/containerd/nydus-snapshotter/pkg/remote/remotes/docker/schema1" //nolint:staticcheck // Ignore SA1019. Need to keep deprecated package for compatibility. remoteerrors "github.com/containerd/nydus-snapshotter/pkg/remote/remotes/errors" diff --git a/pkg/remote/remotes/docker/schema1/converter.go b/pkg/remote/remotes/docker/schema1/converter.go index 9d9ad9ab6d..39ac74a28a 100644 --- a/pkg/remote/remotes/docker/schema1/converter.go +++ b/pkg/remote/remotes/docker/schema1/converter.go @@ -37,7 +37,7 @@ import ( "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/images" "github.com/containerd/containerd/labels" - "github.com/containerd/containerd/log" + "github.com/containerd/log" "github.com/containerd/nydus-snapshotter/pkg/remote/remotes" digest "github.com/opencontainers/go-digest" specs "github.com/opencontainers/image-spec/specs-go" diff --git a/pkg/remote/remotes/handlers.go b/pkg/remote/remotes/handlers.go index 31de555164..8f00898608 100644 --- a/pkg/remote/remotes/handlers.go +++ b/pkg/remote/remotes/handlers.go @@ -29,8 +29,8 @@ import ( "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/images" "github.com/containerd/containerd/labels" - "github.com/containerd/containerd/log" "github.com/containerd/containerd/platforms" + "github.com/containerd/log" ocispec "github.com/opencontainers/image-spec/specs-go/v1" "golang.org/x/sync/semaphore" ) diff --git a/pkg/snapshot/storage.go b/pkg/snapshot/storage.go index ea03b9aa58..3a6f973af0 100644 --- a/pkg/snapshot/storage.go +++ b/pkg/snapshot/storage.go @@ -9,9 +9,9 @@ package snapshot import ( "context" - "github.com/containerd/containerd/log" "github.com/containerd/containerd/snapshots" "github.com/containerd/containerd/snapshots/storage" + "github.com/containerd/log" "github.com/containerd/nydus-snapshotter/pkg/errdefs" "github.com/pkg/errors" ) diff --git a/pkg/stargz/resolver.go b/pkg/stargz/resolver.go index bed128f927..2182aee057 100644 --- a/pkg/stargz/resolver.go +++ b/pkg/stargz/resolver.go @@ -20,8 +20,8 @@ import ( "github.com/pkg/errors" - "github.com/containerd/containerd/log" "github.com/containerd/containerd/reference/docker" + "github.com/containerd/log" "github.com/containerd/nydus-snapshotter/pkg/utils/transport" "github.com/google/go-containerregistry/pkg/authn" "github.com/google/go-containerregistry/pkg/name" diff --git a/pkg/store/database.go b/pkg/store/database.go index dfa5b0ca38..c227a4a59e 100644 --- a/pkg/store/database.go +++ b/pkg/store/database.go @@ -14,7 +14,7 @@ import ( "path/filepath" "time" - "github.com/containerd/containerd/log" + "github.com/containerd/log" "github.com/containerd/nydus-snapshotter/pkg/daemon" "github.com/containerd/nydus-snapshotter/pkg/errdefs" "github.com/containerd/nydus-snapshotter/pkg/rafs" diff --git a/pkg/store/database_compat.go b/pkg/store/database_compat.go index 53edb402d5..afd731000c 100644 --- a/pkg/store/database_compat.go +++ b/pkg/store/database_compat.go @@ -14,7 +14,7 @@ import ( "path" "path/filepath" - "github.com/containerd/containerd/log" + "github.com/containerd/log" "github.com/containerd/nydus-snapshotter/config" "github.com/containerd/nydus-snapshotter/pkg/daemon" "github.com/containerd/nydus-snapshotter/pkg/errdefs" diff --git a/pkg/supervisor/supervisor.go b/pkg/supervisor/supervisor.go index c22f8aea34..2705c9ee5f 100644 --- a/pkg/supervisor/supervisor.go +++ b/pkg/supervisor/supervisor.go @@ -16,7 +16,7 @@ import ( "path/filepath" - "github.com/containerd/containerd/log" + "github.com/containerd/log" "github.com/containerd/nydus-snapshotter/pkg/errdefs" "github.com/pkg/errors" diff --git a/pkg/system/system.go b/pkg/system/system.go index 1c866d22ee..6852eae1b0 100644 --- a/pkg/system/system.go +++ b/pkg/system/system.go @@ -20,7 +20,7 @@ import ( "strings" "time" - "github.com/containerd/containerd/log" + "github.com/containerd/log" "github.com/gorilla/mux" "github.com/pkg/errors" diff --git a/pkg/tarfs/tarfs.go b/pkg/tarfs/tarfs.go index afe96839ee..aa7250f96b 100755 --- a/pkg/tarfs/tarfs.go +++ b/pkg/tarfs/tarfs.go @@ -22,8 +22,8 @@ import ( "syscall" "github.com/containerd/containerd/archive/compression" - "github.com/containerd/containerd/log" "github.com/containerd/containerd/snapshots/storage" + "github.com/containerd/log" "github.com/containerd/nydus-snapshotter/config" "github.com/containerd/nydus-snapshotter/pkg/auth" "github.com/containerd/nydus-snapshotter/pkg/errdefs" diff --git a/pkg/utils/erofs/erofs.go b/pkg/utils/erofs/erofs.go index f50ced04aa..6c71aaf59d 100644 --- a/pkg/utils/erofs/erofs.go +++ b/pkg/utils/erofs/erofs.go @@ -9,7 +9,7 @@ package erofs import ( "fmt" - "github.com/containerd/containerd/log" + "github.com/containerd/log" "github.com/opencontainers/go-digest" "github.com/pkg/errors" "golang.org/x/sys/unix" diff --git a/pkg/utils/transport/pool.go b/pkg/utils/transport/pool.go index 989730cc89..81c5898ed2 100644 --- a/pkg/utils/transport/pool.go +++ b/pkg/utils/transport/pool.go @@ -8,7 +8,7 @@ import ( "sync" "time" - "github.com/containerd/containerd/log" + "github.com/containerd/log" "github.com/containerd/nydus-snapshotter/pkg/utils/registry" "github.com/golang/groupcache/lru" "github.com/google/go-containerregistry/pkg/authn" diff --git a/snapshot/mount_option.go b/snapshot/mount_option.go index 50624e73de..d0161e726b 100644 --- a/snapshot/mount_option.go +++ b/snapshot/mount_option.go @@ -15,10 +15,10 @@ import ( "os" "strings" - "github.com/containerd/containerd/log" "github.com/containerd/containerd/mount" "github.com/containerd/containerd/snapshots" "github.com/containerd/containerd/snapshots/storage" + "github.com/containerd/log" "github.com/containerd/nydus-snapshotter/config/daemonconfig" "github.com/containerd/nydus-snapshotter/pkg/label" "github.com/containerd/nydus-snapshotter/pkg/layout" diff --git a/snapshot/snapshot.go b/snapshot/snapshot.go index 27134ffe32..3b6a61946b 100644 --- a/snapshot/snapshot.go +++ b/snapshot/snapshot.go @@ -16,12 +16,12 @@ import ( "github.com/pkg/errors" - "github.com/containerd/containerd/log" "github.com/containerd/containerd/mount" snpkg "github.com/containerd/containerd/pkg/snapshotters" "github.com/containerd/containerd/snapshots" "github.com/containerd/containerd/snapshots/storage" "github.com/containerd/continuity/fs" + "github.com/containerd/log" "github.com/containerd/nydus-snapshotter/config" "github.com/containerd/nydus-snapshotter/config/daemonconfig" "github.com/containerd/nydus-snapshotter/pkg/rafs" diff --git a/tests/converter_test.go b/tests/converter_test.go index bb4baf81a8..bf436daccb 100644 --- a/tests/converter_test.go +++ b/tests/converter_test.go @@ -31,9 +31,9 @@ import ( "github.com/aws/aws-sdk-go-v2/service/s3" "github.com/containerd/containerd" containerdconverter "github.com/containerd/containerd/images/converter" - "github.com/containerd/containerd/log" "github.com/containerd/containerd/namespaces" "github.com/containerd/containerd/platforms" + "github.com/containerd/log" "github.com/opencontainers/go-digest" "github.com/sirupsen/logrus" "github.com/stretchr/testify/require"