From e45ed5ca0465c083b000774cbd04151566f62fd7 Mon Sep 17 00:00:00 2001 From: Cesar Araujo Date: Fri, 13 Dec 2024 18:16:51 -0600 Subject: [PATCH] removed all panic funcs that were just logging --- .../remoterestartconsumer.go | 8 +----- ee/debug/shipper/shipper.go | 9 +------ ee/desktop/runner/runner.go | 25 +++---------------- ee/desktop/user/menu/menu_systray.go | 8 +----- ee/localserver/server.go | 7 +----- pkg/debug/debug.go | 7 +----- pkg/debug/signal_debug.go | 7 +----- pkg/log/logshipper/logshipper.go | 7 +----- pkg/rungroup/rungroup.go | 8 +----- 9 files changed, 12 insertions(+), 74 deletions(-) diff --git a/ee/control/consumers/remoterestartconsumer/remoterestartconsumer.go b/ee/control/consumers/remoterestartconsumer/remoterestartconsumer.go index 1fa73f9c7..8b2f2c843 100644 --- a/ee/control/consumers/remoterestartconsumer/remoterestartconsumer.go +++ b/ee/control/consumers/remoterestartconsumer/remoterestartconsumer.go @@ -101,13 +101,7 @@ func (r *RemoteRestartConsumer) Do(data io.Reader) error { ) return } - }, func(err any) { - r.slogger.Log(context.TODO(), slog.LevelError, - "exiting after remote restart panic", - "err", err, - "action_run_id", restartAction.RunID, - ) - }) + }, func(err any) {}) return nil } diff --git a/ee/debug/shipper/shipper.go b/ee/debug/shipper/shipper.go index b1cf1e83d..ea166b1c8 100644 --- a/ee/debug/shipper/shipper.go +++ b/ee/debug/shipper/shipper.go @@ -9,7 +9,6 @@ import ( "encoding/json" "fmt" "io" - "log/slog" "net/http" "net/url" "os" @@ -113,13 +112,7 @@ func (s *shipper) Write(p []byte) (n int, err error) { defer s.uploadRequestWg.Done() // will close the body in the close function s.uploadResponse, s.uploadRequestErr = http.DefaultClient.Do(s.uploadRequest) //nolint:bodyclose - }, func(r any) { - s.knapsack.Slogger().Log(context.TODO(), slog.LevelError, - "exiting after upload request panic", - "err", r, - ) - s.uploadRequestErr = fmt.Errorf("upload request panic: %v", r) - }) + }, func(r any) {}) return s.writer.Write(p) } diff --git a/ee/desktop/runner/runner.go b/ee/desktop/runner/runner.go index 1af0903c3..cf3d9e060 100644 --- a/ee/desktop/runner/runner.go +++ b/ee/desktop/runner/runner.go @@ -192,12 +192,7 @@ func New(k types.Knapsack, messenger runnerserver.Messenger, opts ...desktopUser "err", err, ) } - }, func(err any) { - runner.slogger.Log(context.TODO(), slog.LevelError, - "exiting after monitor server panic", - "err", err, - ) - }) + }, func(err any) {}) if runtime.GOOS == "darwin" { runner.osVersion, err = osversion() @@ -318,12 +313,7 @@ func (r *DesktopUsersProcessesRunner) killDesktopProcesses(ctx context.Context) gowrapper.Go(context.TODO(), r.slogger, func() { defer close(wgDone) r.procsWg.Wait() - }, func(err any) { - r.slogger.Log(context.TODO(), slog.LevelError, - "exiting after wait group panic", - "err", err, - ) - }) + }, func(err any) {}) shutdownRequestCount := 0 for uid, proc := range r.uidProcs { @@ -796,7 +786,7 @@ func (r *DesktopUsersProcessesRunner) addProcessTrackingRecordForUser(uid string // The wait group is needed to prevent races. func (r *DesktopUsersProcessesRunner) waitOnProcessAsync(uid string, proc *os.Process) { r.procsWg.Add(1) - gowrapper.Go(context.TODO(), r.slogger, func() { + gowrapper.Go(context.TODO(), r.slogger.With("uid", uid, "pid", proc.Pid), func() { defer r.procsWg.Done() // waiting here gives the parent a chance to clean up state, err := proc.Wait() @@ -809,14 +799,7 @@ func (r *DesktopUsersProcessesRunner) waitOnProcessAsync(uid string, proc *os.Pr "state", state, ) } - }, func(err any) { - r.slogger.Log(context.TODO(), slog.LevelError, - "exiting after process wait panic", - "err", err, - "uid", uid, - "pid", proc.Pid, - ) - }) + }, func(err any) {}) } // determineExecutablePath returns DesktopUsersProcessesRunner.executablePath if it is set, diff --git a/ee/desktop/user/menu/menu_systray.go b/ee/desktop/user/menu/menu_systray.go index 22acf7de0..27892b884 100644 --- a/ee/desktop/user/menu/menu_systray.go +++ b/ee/desktop/user/menu/menu_systray.go @@ -2,7 +2,6 @@ package menu import ( "context" - "log/slog" "sync" "github.com/kolide/launcher/ee/gowrapper" @@ -134,10 +133,5 @@ func (m *menu) makeActionHandler(item *systray.MenuItem, ap ActionPerformer) { return } } - }, func(r any) { - m.slogger.Log(context.TODO(), slog.LevelError, - "exiting after menu action handler panic", - "err", r, - ) - }) + }, func(r any) {}) } diff --git a/ee/localserver/server.go b/ee/localserver/server.go index c8586c5c3..053c09de4 100644 --- a/ee/localserver/server.go +++ b/ee/localserver/server.go @@ -279,12 +279,7 @@ func (ls *localServer) Start() error { } } } - }, func(r any) { - ls.slogger.Log(ctx, slog.LevelError, - "exiting after background worker panic", - "err", r, - ) - }) + }, func(r any) {}) l, err := ls.startListener() if err != nil { diff --git a/pkg/debug/debug.go b/pkg/debug/debug.go index e73c6fa75..0f1c884f4 100644 --- a/pkg/debug/debug.go +++ b/pkg/debug/debug.go @@ -50,12 +50,7 @@ func startDebugServer(addrPath string, slogger *slog.Logger) (*http.Server, erro "err", err, ) } - }, func(r any) { - slogger.Log(context.TODO(), slog.LevelError, - "exiting after debug server panic", - "err", r, - ) - }) + }, func(r any) {}) url := url.URL{ Scheme: "http", diff --git a/pkg/debug/signal_debug.go b/pkg/debug/signal_debug.go index 88a3ac741..c7efee6bb 100644 --- a/pkg/debug/signal_debug.go +++ b/pkg/debug/signal_debug.go @@ -47,11 +47,6 @@ func AttachDebugHandler(addrPath string, slogger *slog.Logger) { "shutdown debug server", ) } - }, func(r any) { - slogger.Log(context.TODO(), slog.LevelError, - "exiting after debug signal handler panic", - "err", r, - ) - }) + }, func(r any) {}) } diff --git a/pkg/log/logshipper/logshipper.go b/pkg/log/logshipper/logshipper.go index e709e5a87..4977300dd 100644 --- a/pkg/log/logshipper/logshipper.go +++ b/pkg/log/logshipper/logshipper.go @@ -117,12 +117,7 @@ func (ls *LogShipper) Ping() { ls.isShippingStarted = true gowrapper.Go(context.TODO(), ls.knapsack.Slogger(), func() { ls.startShippingChan <- struct{}{} - }, func(r any) { - ls.knapsack.Slogger().Log(context.TODO(), slog.LevelError, - "exiting after shipping channel send panic", - "err", r, - ) - }) + }, func(r any) {}) } diff --git a/pkg/rungroup/rungroup.go b/pkg/rungroup/rungroup.go index a62a76f8f..3ee551ce6 100644 --- a/pkg/rungroup/rungroup.go +++ b/pkg/rungroup/rungroup.go @@ -124,13 +124,7 @@ func (g *Group) Run() error { "interrupt complete", "actor", a.name, ) - }, func(r any) { - g.slogger.Log(context.TODO(), slog.LevelError, - "exiting after actor interrupt panic", - "err", r, - "actor", a.name, - ) - }) + }, func(r any) {}) } interruptCtx, interruptCancel := context.WithTimeout(context.Background(), InterruptTimeout)