Merge pull request #9016 from djdongjin/remove-most-logrus
Remove most logrus import
This commit is contained in:
@@ -36,7 +36,6 @@ import (
|
||||
ctrdutil "github.com/containerd/containerd/pkg/cri/util"
|
||||
"github.com/containerd/containerd/protobuf"
|
||||
"github.com/containerd/typeurl/v2"
|
||||
"github.com/sirupsen/logrus"
|
||||
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
|
||||
"k8s.io/utils/clock"
|
||||
)
|
||||
@@ -264,18 +263,18 @@ func (em *eventMonitor) start() <-chan error {
|
||||
break
|
||||
}
|
||||
if em.backOff.isInBackOff(id) {
|
||||
logrus.Infof("Events for %q is in backoff, enqueue event %+v", id, evt)
|
||||
log.L.Infof("Events for %q is in backoff, enqueue event %+v", id, evt)
|
||||
em.backOff.enBackOff(id, evt)
|
||||
break
|
||||
}
|
||||
if err := em.handleEvent(evt); err != nil {
|
||||
logrus.WithError(err).Errorf("Failed to handle event %+v for %s", evt, id)
|
||||
log.L.WithError(err).Errorf("Failed to handle event %+v for %s", evt, id)
|
||||
em.backOff.enBackOff(id, evt)
|
||||
}
|
||||
case err := <-em.errCh:
|
||||
// Close errCh in defer directly if there is no error.
|
||||
if err != nil {
|
||||
logrus.WithError(err).Error("Failed to handle event stream")
|
||||
log.L.WithError(err).Error("Failed to handle event stream")
|
||||
errCh <- err
|
||||
}
|
||||
return
|
||||
@@ -285,7 +284,7 @@ func (em *eventMonitor) start() <-chan error {
|
||||
queue := em.backOff.deBackOff(id)
|
||||
for i, evt := range queue.events {
|
||||
if err := em.handleEvent(evt); err != nil {
|
||||
logrus.WithError(err).Errorf("Failed to handle backOff event %+v for %s", evt, id)
|
||||
log.L.WithError(err).Errorf("Failed to handle backOff event %+v for %s", evt, id)
|
||||
em.backOff.reBackOff(id, queue.events[i:], queue.duration)
|
||||
break
|
||||
}
|
||||
@@ -312,7 +311,7 @@ func (em *eventMonitor) handleEvent(any interface{}) error {
|
||||
|
||||
switch e := any.(type) {
|
||||
case *eventtypes.TaskExit:
|
||||
logrus.Infof("TaskExit event %+v", e)
|
||||
log.G(ctx).Infof("TaskExit event %+v", e)
|
||||
// Use ID instead of ContainerID to rule out TaskExit event for exec.
|
||||
cntr, err := em.c.containerStore.Get(e.ID)
|
||||
if err == nil {
|
||||
@@ -334,7 +333,7 @@ func (em *eventMonitor) handleEvent(any interface{}) error {
|
||||
}
|
||||
return nil
|
||||
case *eventtypes.TaskOOM:
|
||||
logrus.Infof("TaskOOM event %+v", e)
|
||||
log.G(ctx).Infof("TaskOOM event %+v", e)
|
||||
// For TaskOOM, we only care which container it belongs to.
|
||||
cntr, err := em.c.containerStore.Get(e.ContainerID)
|
||||
if err != nil {
|
||||
@@ -351,13 +350,13 @@ func (em *eventMonitor) handleEvent(any interface{}) error {
|
||||
return fmt.Errorf("failed to update container status for TaskOOM event: %w", err)
|
||||
}
|
||||
case *eventtypes.ImageCreate:
|
||||
logrus.Infof("ImageCreate event %+v", e)
|
||||
log.G(ctx).Infof("ImageCreate event %+v", e)
|
||||
return em.c.updateImage(ctx, e.Name)
|
||||
case *eventtypes.ImageUpdate:
|
||||
logrus.Infof("ImageUpdate event %+v", e)
|
||||
log.G(ctx).Infof("ImageUpdate event %+v", e)
|
||||
return em.c.updateImage(ctx, e.Name)
|
||||
case *eventtypes.ImageDelete:
|
||||
logrus.Infof("ImageDelete event %+v", e)
|
||||
log.G(ctx).Infof("ImageDelete event %+v", e)
|
||||
return em.c.updateImage(ctx, e.Name)
|
||||
}
|
||||
|
||||
@@ -436,7 +435,7 @@ func handleContainerExit(ctx context.Context, e *eventtypes.TaskExit, cntr conta
|
||||
return fmt.Errorf("failed to cleanup container %s in task-service: %w", cntr.Container.ID(), err)
|
||||
}
|
||||
}
|
||||
logrus.Infof("Ensure that container %s in task-service has been cleanup successfully", cntr.Container.ID())
|
||||
log.G(ctx).Infof("Ensure that container %s in task-service has been cleanup successfully", cntr.Container.ID())
|
||||
}
|
||||
|
||||
err = cntr.Status.UpdateSync(func(status containerstore.Status) (containerstore.Status, error) {
|
||||
@@ -449,7 +448,7 @@ func handleContainerExit(ctx context.Context, e *eventtypes.TaskExit, cntr conta
|
||||
// Unknown state can only transit to EXITED state, so we need
|
||||
// to handle unknown state here.
|
||||
if status.Unknown {
|
||||
logrus.Debugf("Container %q transited from UNKNOWN to EXITED", cntr.ID)
|
||||
log.G(ctx).Debugf("Container %q transited from UNKNOWN to EXITED", cntr.ID)
|
||||
status.Unknown = false
|
||||
}
|
||||
return status, nil
|
||||
@@ -522,7 +521,7 @@ func handleSandboxExit(ctx context.Context, e *eventtypes.TaskExit, sb sandboxst
|
||||
return fmt.Errorf("failed to cleanup sandbox %s in task-service: %w", sb.Container.ID(), err)
|
||||
}
|
||||
}
|
||||
logrus.Infof("Ensure that sandbox %s in task-service has been cleanup successfully", sb.Container.ID())
|
||||
log.G(ctx).Infof("Ensure that sandbox %s in task-service has been cleanup successfully", sb.Container.ID())
|
||||
}
|
||||
err = sb.Status.Update(func(status sandboxstore.Status) (sandboxstore.Status, error) {
|
||||
status.State = sandboxstore.StateNotReady
|
||||
|
||||
@@ -41,7 +41,6 @@ import (
|
||||
runcoptions "github.com/containerd/containerd/runtime/v2/runc/options"
|
||||
"github.com/containerd/typeurl/v2"
|
||||
runtimespec "github.com/opencontainers/runtime-spec/specs-go"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
||||
runhcsoptions "github.com/Microsoft/hcsshim/cmd/containerd-shim-runhcs-v1/options"
|
||||
imagedigest "github.com/opencontainers/go-digest"
|
||||
@@ -519,7 +518,7 @@ func (c *criService) generateAndSendContainerEvent(ctx context.Context, containe
|
||||
}
|
||||
containerStatuses, err := c.getContainerStatuses(ctx, sandboxID)
|
||||
if err != nil {
|
||||
logrus.Errorf("Failed to get container statuses for container event for sandboxID %q: %v", sandboxID, err)
|
||||
log.G(ctx).Errorf("Failed to get container statuses for container event for sandboxID %q: %v", sandboxID, err)
|
||||
}
|
||||
|
||||
event := runtime.ContainerEventResponse{
|
||||
@@ -535,7 +534,7 @@ func (c *criService) generateAndSendContainerEvent(ctx context.Context, containe
|
||||
case c.containerEventsChan <- event:
|
||||
default:
|
||||
containerEventsDroppedCount.Inc()
|
||||
logrus.Debugf("containerEventsChan is full, discarding event %+v", event)
|
||||
log.G(ctx).Debugf("containerEventsChan is full, discarding event %+v", event)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,6 @@ import (
|
||||
"github.com/containerd/containerd/pkg/kmutex"
|
||||
"github.com/containerd/containerd/plugin"
|
||||
cni "github.com/containerd/go-cni"
|
||||
"github.com/sirupsen/logrus"
|
||||
"google.golang.org/grpc"
|
||||
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
|
||||
|
||||
@@ -304,10 +303,10 @@ func (c *criService) Run(ready func()) error {
|
||||
// Close stops the CRI service.
|
||||
// TODO(random-liu): Make close synchronous.
|
||||
func (c *criService) Close() error {
|
||||
logrus.Info("Stop CRI service")
|
||||
log.L.Info("Stop CRI service")
|
||||
for name, h := range c.cniNetConfMonitor {
|
||||
if err := h.stop(); err != nil {
|
||||
logrus.WithError(err).Errorf("failed to stop cni network conf monitor for %s", name)
|
||||
log.L.WithError(err).Errorf("failed to stop cni network conf monitor for %s", name)
|
||||
}
|
||||
}
|
||||
c.eventMonitor.stop()
|
||||
|
||||
Reference in New Issue
Block a user