Merge pull request #10349 from thaJeztah/less_logrus

Remove some logrus imports
This commit is contained in:
Derek McGowan 2024-06-17 17:42:29 +00:00 committed by GitHub
commit 4770618c7b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 18 additions and 24 deletions

View File

@ -29,7 +29,7 @@ import (
"time"
"github.com/containerd/containerd/v2/pkg/userns"
"github.com/sirupsen/logrus"
"github.com/containerd/log"
"golang.org/x/sys/unix"
)
@ -253,11 +253,11 @@ func doPrepareIDMappedOverlay(lowerDirs []string, usernsFd int) (tmpLowerDirs []
cleanUp := func() {
for _, lowerDir := range tmpLowerDirs {
if err := unix.Unmount(lowerDir, 0); err != nil {
logrus.WithError(err).Warnf("failed to unmount temp lowerdir %s", lowerDir)
log.L.WithError(err).Warnf("failed to unmount temp lowerdir %s", lowerDir)
}
}
if terr := os.RemoveAll(filepath.Clean(filepath.Join(tmpLowerDirs[0], ".."))); terr != nil {
logrus.WithError(terr).Warnf("failed to remove temporary overlay lowerdir's")
log.L.WithError(terr).Warnf("failed to remove temporary overlay lowerdir's")
}
}
for i, lowerDir := range lowerDirs {

View File

@ -30,7 +30,6 @@ import (
"github.com/containerd/errdefs"
"github.com/containerd/log"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/sirupsen/logrus"
)
func (ts *localTransferService) pull(ctx context.Context, ir transfer.ImageFetcher, is transfer.ImageStorer, tops *transfer.Config) error {
@ -57,28 +56,28 @@ func (ts *localTransferService) pull(ctx context.Context, ir transfer.ImageFetch
// Verify image before pulling.
for vfName, vf := range ts.config.Verifiers {
log := log.G(ctx).WithFields(logrus.Fields{
logger := log.G(ctx).WithFields(log.Fields{
"name": name,
"digest": desc.Digest.String(),
"verifier": vfName,
})
log.Debug("Verifying image pull")
logger.Debug("Verifying image pull")
jdg, err := vf.VerifyImage(ctx, name, desc)
if err != nil {
log.WithError(err).Error("No judgement received from verifier")
logger.WithError(err).Error("No judgement received from verifier")
return fmt.Errorf("blocking pull of %v with digest %v: image verifier %v returned error: %w", name, desc.Digest.String(), vfName, err)
}
log = log.WithFields(logrus.Fields{
logger = logger.WithFields(log.Fields{
"ok": jdg.OK,
"reason": jdg.Reason,
})
if !jdg.OK {
log.Warn("Image verifier blocked pull")
logger.Warn("Image verifier blocked pull")
return fmt.Errorf("image verifier %s blocked pull of %v with digest %v for reason: %v", vfName, name, desc.Digest.String(), jdg.Reason)
}
log.Debug("Image verifier allowed pull")
logger.Debug("Image verifier allowed pull")
}
// TODO: Handle already exists

View File

@ -43,7 +43,6 @@ import (
"github.com/containerd/plugin"
"github.com/containerd/plugin/registry"
"github.com/containerd/ttrpc"
"github.com/sirupsen/logrus"
)
// Publisher for events
@ -171,12 +170,9 @@ func setRuntime() {
func setLogger(ctx context.Context, id string) (context.Context, error) {
l := log.G(ctx)
l.Logger.SetFormatter(&logrus.TextFormatter{
TimestampFormat: log.RFC3339NanoFixed,
FullTimestamp: true,
})
_ = log.SetFormat(log.TextFormat)
if debugFlag {
l.Logger.SetLevel(log.DebugLevel)
_ = log.SetLevel("debug")
}
f, err := openLog(ctx, id)
if err != nil {

View File

@ -30,7 +30,6 @@ import (
"github.com/containerd/containerd/v2/pkg/sys/reaper"
"github.com/containerd/fifo"
"github.com/containerd/log"
"github.com/sirupsen/logrus"
"golang.org/x/sys/unix"
)
@ -71,7 +70,7 @@ func serveListener(path string) (net.Listener, error) {
return l, nil
}
func reap(ctx context.Context, logger *logrus.Entry, signals chan os.Signal) error {
func reap(ctx context.Context, logger *log.Entry, signals chan os.Signal) error {
logger.Debug("starting signal loop")
for {
@ -92,7 +91,7 @@ func reap(ctx context.Context, logger *logrus.Entry, signals chan os.Signal) err
}
}
func handleExitSignals(ctx context.Context, logger *logrus.Entry, cancel context.CancelFunc) {
func handleExitSignals(ctx context.Context, logger *log.Entry, cancel context.CancelFunc) {
ch := make(chan os.Signal, 32)
signal.Notify(ch, syscall.SIGINT, syscall.SIGTERM)

View File

@ -23,8 +23,8 @@ import (
"os"
"github.com/containerd/errdefs"
"github.com/containerd/log"
"github.com/containerd/ttrpc"
"github.com/sirupsen/logrus"
)
func setupSignals(config Config) (chan os.Signal, error) {
@ -46,11 +46,11 @@ func serveListener(path string) (net.Listener, error) {
return nil, errdefs.ErrNotImplemented
}
func reap(ctx context.Context, logger *logrus.Entry, signals chan os.Signal) error {
func reap(ctx context.Context, logger *log.Entry, signals chan os.Signal) error {
return errdefs.ErrNotImplemented
}
func handleExitSignals(ctx context.Context, logger *logrus.Entry, cancel context.CancelFunc) {
func handleExitSignals(ctx context.Context, logger *log.Entry, cancel context.CancelFunc) {
}
func openLog(ctx context.Context, _ string) (io.Writer, error) {