Skip to content

Commit

Permalink
removed all panic funcs that were just logging
Browse files Browse the repository at this point in the history
  • Loading branch information
cesarfda committed Dec 14, 2024
1 parent 5b33121 commit e45ed5c
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
9 changes: 1 addition & 8 deletions ee/debug/shipper/shipper.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"encoding/json"
"fmt"
"io"
"log/slog"
"net/http"
"net/url"
"os"
Expand Down Expand Up @@ -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)
}
Expand Down
25 changes: 4 additions & 21 deletions ee/desktop/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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()
Expand All @@ -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,
Expand Down
8 changes: 1 addition & 7 deletions ee/desktop/user/menu/menu_systray.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package menu

import (
"context"
"log/slog"
"sync"

"github.com/kolide/launcher/ee/gowrapper"
Expand Down Expand Up @@ -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) {})
}
7 changes: 1 addition & 6 deletions ee/localserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 1 addition & 6 deletions pkg/debug/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
7 changes: 1 addition & 6 deletions pkg/debug/signal_debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {})

}
7 changes: 1 addition & 6 deletions pkg/log/logshipper/logshipper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {})

}

Expand Down
8 changes: 1 addition & 7 deletions pkg/rungroup/rungroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit e45ed5c

Please sign in to comment.