From ff2dacd92cef09d252ed871b1ce5aeb00cd486b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Date: Mon, 26 Apr 2021 11:04:43 +0200 Subject: [PATCH] main: still rely on logrus (rather than using the internal log) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is a partial revert of 975ffc6e482ab8581410b445c2268d60d64be62d, where we started using the internal log when the context is avaiable. It turns out that we missed a few pieces during the review, where we end up using the internal log without having the interceptors set up. This was raised by @haircommander during the review, we checked a few parts of the patch, but we still missed a few others. We can only use the internal logging after https://github.com/cri-o/cri-o/blob/d3dbaec060e33870e5cb5c3f7ec4207837804b00/cmd/crio/main.go#L222 happens. From this moment, we start having different ways of logging in the very same file and consistency becomes a problem then. With the consistency in mind, I'd like to **only** use logrus for debugging as part of this file. Note: This was noticed when debugging https://github.com/cri-o/cri-o/issues/4798 Signed-off-by: Fabiano FidĂȘncio --- cmd/crio/main.go | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/cmd/crio/main.go b/cmd/crio/main.go index 2fe58295ebe..56df30b6263 100644 --- a/cmd/crio/main.go +++ b/cmd/crio/main.go @@ -63,9 +63,9 @@ func catchShutdown(ctx context.Context, cancel context.CancelFunc, gserver *grpc case unix.SIGPIPE: continue case signals.Interrupt: - log.Debugf(ctx, "Caught SIGINT") + logrus.Debugf("Caught SIGINT") case signals.Term: - log.Debugf(ctx, "Caught SIGTERM") + logrus.Debugf("Caught SIGTERM") default: continue } @@ -73,12 +73,12 @@ func catchShutdown(ctx context.Context, cancel context.CancelFunc, gserver *grpc gserver.GracefulStop() hserver.Shutdown(ctx) // nolint: errcheck if err := sserver.StopStreamServer(); err != nil { - log.Warnf(ctx, "error shutting down streaming server: %v", err) + logrus.Warnf("error shutting down streaming server: %v", err) } sserver.StopMonitors() cancel() if err := sserver.Shutdown(ctx); err != nil { - log.Warnf(ctx, "error shutting down main service %v", err) + logrus.Warnf("error shutting down main service %v", err) } return } @@ -185,9 +185,9 @@ func main() { profilePort := c.Int("profile-port") profileEndpoint := fmt.Sprintf("localhost:%v", profilePort) go func() { - log.Debugf(ctx, "starting profiling server on %v", profileEndpoint) + logrus.Debugf("starting profiling server on %v", profileEndpoint) if err := http.ListenAndServe(profileEndpoint, nil); err != nil { - log.Fatalf(ctx, "unable to run profiling server: %v", err) + logrus.Fatalf("unable to run profiling server: %v", err) } }() } @@ -211,7 +211,7 @@ func main() { lis, err := server.Listen("unix", config.Listen) if err != nil { - log.Fatalf(ctx, "failed to listen: %v", err) + logrus.Fatalf("failed to listen: %v", err) } grpcServer := grpc.NewServer( @@ -254,13 +254,13 @@ func main() { // CleanShutdownFile. f, err := os.Create(config.CleanShutdownSupportedFileName()) if err != nil { - log.Errorf(ctx, "Writing clean shutdown supported file: %v", err) + logrus.Errorf("Writing clean shutdown supported file: %v", err) } f.Close() // and sync the changes to disk if err := utils.SyncParent(config.CleanShutdownFile); err != nil { - log.Errorf(ctx, "failed to sync parent directory of clean shutdown file: %v", err) + logrus.Errorf("failed to sync parent directory of clean shutdown file: %v", err) } } @@ -300,12 +300,12 @@ func main() { go func() { if err := grpcServer.Serve(grpcL); err != nil { - log.Errorf(ctx, "unable to run GRPC server: %v", err) + logrus.Errorf("unable to run GRPC server: %v", err) } }() go func() { if err := httpServer.Serve(httpL); err != nil { - log.Debugf(ctx, "closed http server") + logrus.Debugf("closed http server") } }() @@ -316,7 +316,7 @@ func main() { if graceful && strings.Contains(strings.ToLower(err.Error()), "use of closed network connection") { err = nil } else { - log.Errorf(ctx, "Failed to serve grpc request: %v", err) + logrus.Errorf("Failed to serve grpc request: %v", err) } } }() @@ -330,22 +330,22 @@ func main() { } if err := crioServer.Shutdown(ctx); err != nil { - log.Warnf(ctx, "error shutting down service: %v", err) + logrus.Warnf("error shutting down service: %v", err) } cancel() <-streamServerCloseCh - log.Debugf(ctx, "closed stream server") + logrus.Debugf("closed stream server") <-serverMonitorsCh - log.Debugf(ctx, "closed monitors") + logrus.Debugf("closed monitors") err = <-hookSync if err == nil || err == context.Canceled { - log.Debugf(ctx, "closed hook monitor") + logrus.Debugf("closed hook monitor") } else { - log.Errorf(ctx, "hook monitor failed: %v", err) + logrus.Errorf("hook monitor failed: %v", err) } <-serverCloseCh - log.Debugf(ctx, "closed main server") + logrus.Debugf("closed main server") return nil }