Skip to content

Commit

Permalink
Use actual systray error instead of const string
Browse files Browse the repository at this point in the history
  • Loading branch information
RebeccaMahany committed Aug 19, 2024
1 parent 6507c14 commit 07b7f94
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ee/desktop/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -950,7 +950,7 @@ func (r *DesktopUsersProcessesRunner) processLogs(uid string, stdErr io.ReadClos
// Check to see if the log line contains systrayNeedsRestartErr.
// systray is not able to self-recover from the systrayNeedsRestartErr,
// so if we see it even once, we should take action.
if !strings.Contains(logLine, systrayNeedsRestartErr) {
if !logIndicatesSystrayNeedsRestart(logLine) {
continue
}

Expand Down
5 changes: 5 additions & 0 deletions ee/desktop/runner/runner_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,8 @@ func (r *DesktopUsersProcessesRunner) runAsUser(ctx context.Context, uid string,
func osversion() (string, error) {
return unix.Sysctl("kern.osrelease")
}

// logIndicatesSystrayNeedsRestart is Windows-only functionality
func logIndicatesSystrayNeedsRestart(_ string) bool {
return false
}
5 changes: 5 additions & 0 deletions ee/desktop/runner/runner_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -387,3 +387,8 @@ func getXdgRuntimeDir(uid string) string {
func osversion() (string, error) {
return "", errors.New("not implemented")
}

// logIndicatesSystrayNeedsRestart is Windows-only functionality
func logIndicatesSystrayNeedsRestart(_ string) bool {
return false
}
9 changes: 9 additions & 0 deletions ee/desktop/runner/runner_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ import (
"errors"
"fmt"
"os/exec"
"strings"
"syscall"

"github.com/kolide/launcher/ee/consoleuser"
"github.com/kolide/launcher/pkg/traces"
"github.com/kolide/systray"
)

func (r *DesktopUsersProcessesRunner) runAsUser(ctx context.Context, uid string, cmd *exec.Cmd) error {
Expand Down Expand Up @@ -64,3 +66,10 @@ func processAccessToken(pid int32) (syscall.Token, error) {
func osversion() (string, error) {
return "", errors.New("not implemented")
}

// logIndicatesSystrayNeedsRestart checks to see if the log line contains
// "tray not ready yet", which indicates that the systray had an irrecoverable
// error during initialization and requires restart.
func logIndicatesSystrayNeedsRestart(logLine string) bool {
return strings.Contains(logLine, systray.ErrTrayNotReadyYet.Error())
}

0 comments on commit 07b7f94

Please sign in to comment.