kolide / launcher

Osquery launcher, autoupdater, and packager
https://kolide.com/launcher
Other
501 stars 99 forks source link

Make windows desktop process responsive to repeated systray errors #1717

Open zackattack01 opened 1 month ago

zackattack01 commented 1 month ago

We often observe systray errors like tray not ready when devices are asleep - but these can be indicative of persistent issues when repeated after the device has woken up from sleeping. Specifically I saw this pattern on my own device after being in modern standby for a few hours:

logs

``` {"time":"2024-05-15T15:21:56.094156Z","level":"DEBUG","source":{"function":"github.com/kolide/launcher/ee/desktop/runner.(*DesktopUsersProcessesRunner).runConsoleUserDesktop","file":"C:/Users/zack-/code/launcher/ee/desktop/runner/runner.go","line":549},"msg":"modern standby detected, skipping desktop process spawning and health checks","launcher_run_id":"01HXXDRZPD8P7MREKCHWGM71GG","component":"desktop_runner"} {"time":"2024-05-15T15:21:57.2525241Z","level":"DEBUG","source":{"function":"github.com/kolide/launcher/ee/powereventwatcher.(*powerEventWatcher).onPowerEvent","file":"C:/Users/zack-/code/launcher/ee/powereventwatcher/power_event_watcher_windows.go","line":206},"msg":"system is waking","launcher_run_id":"01HXXDRZPD8P7MREKCHWGM71GG","component":"power_event_watcher","event_id":507} {"time":"2024-05-15T15:21:59.6302959Z","level":"DEBUG","source":{"function":"github.com/kolide/launcher/ee/desktop/runner.(*DesktopUsersProcessesRunner).desktopCommand.func1","file":"C:/Users/zack-/code/launcher/ee/desktop/runner/runner.go","line":870},"msg":"2024/05/15 11:21:59 systray error: unable to init instance: Unspecified error","launcher_run_id":"01HXXDRZPD8P7MREKCHWGM71GG","component":"desktop_runner","uid":"zackwindows\\zack-","subprocess":"desktop"} {"time":"2024-05-15T15:22:00.6140489Z","level":"DEBUG","source":{"function":"github.com/kolide/launcher/ee/desktop/runner.(*DesktopUsersProcessesRunner).spawnForUser","file":"C:/Users/zack-/code/launcher/ee/desktop/runner/runner.go","line":642},"msg":"desktop process started","launcher_run_id":"01HXXDRZPD8P7MREKCHWGM71GG","component":"desktop_runner","uid":"zackwindows\\zack-","pid":9116,"span_id":"9d6bfa57f016979f","trace_id":"5870e93b08f6955c3c6c50a6fce7bc6a","trace_sampled":false} {"time":"2024-05-15T15:22:09.6058173Z","level":"DEBUG","source":{"function":"github.com/kolide/launcher/ee/desktop/runner.(*DesktopUsersProcessesRunner).desktopCommand.func1","file":"C:/Users/zack-/code/launcher/ee/desktop/runner/runner.go","line":870},"msg":"2024/05/15 11:22:09 systray error: unable to set icon: tray not ready yet","launcher_run_id":"01HXXDRZPD8P7MREKCHWGM71GG","component":"desktop_runner","uid":"zackwindows\\zack-","subprocess":"desktop"} {"time":"2024-05-15T15:22:09.6058173Z","level":"DEBUG","source":{"function":"github.com/kolide/launcher/ee/desktop/runner.(*DesktopUsersProcessesRunner).desktopCommand.func1","file":"C:/Users/zack-/code/launcher/ee/desktop/runner/runner.go","line":870},"msg":"2024/05/15 11:22:09 systray error: unable to set tooltip: tray not ready yet","launcher_run_id":"01HXXDRZPD8P7MREKCHWGM71GG","component":"desktop_runner","uid":"zackwindows\\zack-","subprocess":"desktop"} ```

These show the device coming out of modern standby, immediately hitting systray error: unable to init instance: Unspecified, and then repeatedly failing to do anything with systray (systray error: unable to set tooltip: tray not ready yet).

These systray errors are logged from here. It may be a bit tricky but we should be able to make the desktop process aware of this state, so it can either re-initialize the MBA or shut itself down to be restarted by the runner.

Reminder: We should not count errors like these when the device is sleeping/in modern standby