Skip to content

Commit

Permalink
dont interact with desktop client while in standby (#1700)
Browse files Browse the repository at this point in the history
  • Loading branch information
James-Pickett authored Apr 30, 2024
1 parent a3335c0 commit 29687be
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
21 changes: 21 additions & 0 deletions ee/desktop/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,13 @@ func (r *DesktopUsersProcessesRunner) killDesktopProcesses(ctx context.Context)
}

func (r *DesktopUsersProcessesRunner) SendNotification(n notify.Notification) error {
if r.knapsack.InModernStandby() {
r.slogger.Log(context.TODO(), slog.LevelDebug,
"modern standby detected, skipping notification send",
)
return errors.New("modern standby detected, skipping notification send")
}

if len(r.uidProcs) == 0 {
return errors.New("cannot send notification, no child desktop processes")
}
Expand Down Expand Up @@ -436,6 +443,13 @@ func (r *DesktopUsersProcessesRunner) refreshMenu() {
}
}

if r.knapsack.InModernStandby() {
r.slogger.Log(context.TODO(), slog.LevelDebug,
"modern standby detected, skipping menu refresh",
)
return
}

// Tell any running desktop user processes that they should refresh the latest menu data
for uid, proc := range r.uidProcs {
client := client.New(r.userServerAuthToken, proc.socketPath)
Expand Down Expand Up @@ -531,6 +545,13 @@ func (r *DesktopUsersProcessesRunner) writeDefaultMenuTemplateFile() {
}

func (r *DesktopUsersProcessesRunner) runConsoleUserDesktop() error {
if r.knapsack.InModernStandby() {
r.slogger.Log(context.TODO(), slog.LevelDebug,
"modern standby detected, skipping desktop process spawning and health checks",
)
return nil
}

if !r.processSpawningEnabled {
// Desktop is disabled, kill any existing desktop user processes
r.killDesktopProcesses(context.Background())
Expand Down
3 changes: 3 additions & 0 deletions ee/desktop/runner/runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ func TestDesktopUserProcessRunner_Execute(t *testing.T) {
mockKnapsack.On("KolideServerURL").Return("somewhere-over-the-rainbow.example.com")
mockKnapsack.On("DesktopEnabled").Return(true)
mockKnapsack.On("Slogger").Return(slogger)
mockKnapsack.On("InModernStandby").Return(false)

if os.Getenv("CI") != "true" || runtime.GOOS != "linux" {
// Only expect that we call Debug (to set the DEBUG flag on the process) if we actually expect
Expand Down Expand Up @@ -298,6 +299,7 @@ func TestUpdate(t *testing.T) {
mockKnapsack.On("KolideServerURL").Return("somewhere-over-the-rainbow.example.com")
mockKnapsack.On("DesktopEnabled").Return(true)
mockKnapsack.On("Slogger").Return(multislogger.NewNopLogger())
mockKnapsack.On("InModernStandby").Return(false)

dir := t.TempDir()
r, err := New(mockKnapsack, nil, WithUsersFilesRoot(dir))
Expand Down Expand Up @@ -332,6 +334,7 @@ func TestSendNotification_NoProcessesYet(t *testing.T) {
mockKnapsack.On("KolideServerURL").Return("somewhere-over-the-rainbow.example.com")
mockKnapsack.On("DesktopEnabled").Return(true)
mockKnapsack.On("Slogger").Return(multislogger.NewNopLogger())
mockKnapsack.On("InModernStandby").Return(false)

dir := t.TempDir()
r, err := New(mockKnapsack, nil, WithUsersFilesRoot(dir))
Expand Down

0 comments on commit 29687be

Please sign in to comment.