diff --git a/ee/watchdog/controller_windows.go b/ee/watchdog/controller_windows.go index f39a9efc1..e6a54de4a 100644 --- a/ee/watchdog/controller_windows.go +++ b/ee/watchdog/controller_windows.go @@ -93,6 +93,13 @@ func (wc *WatchdogController) publishLogs(ctx context.Context) { return } + // don't bother processing further unless watchdog is enabled. + // note that this means if you manually install watchdog via CLI, logs + // will not be published unless you have the corresponding feature flag enabled + if !wc.knapsack.LauncherWatchdogEnabled() { + return + } + // note that there is a small window here where there could be pending logs before the watchdog task is removed - // there is no harm in leaving them and we could recover these with the original timestamps if we ever needed. // to avoid endlessly re-processing empty logs while we are disabled, we accept this possibility and exit early here diff --git a/ee/watchdog/controller_windows_test.go b/ee/watchdog/controller_windows_test.go index 957f66f7c..619cc3f1a 100644 --- a/ee/watchdog/controller_windows_test.go +++ b/ee/watchdog/controller_windows_test.go @@ -23,6 +23,7 @@ func TestInterrupt_Multiple(t *testing.T) { mockKnapsack.On("Slogger").Return(testSlogger) mockKnapsack.On("Identifier").Return("kolide-k2") mockKnapsack.On("KolideServerURL").Return("k2device.kolide.com") + mockKnapsack.On("LauncherWatchdogEnabled").Return(false).Maybe() controller, _ := NewController(context.TODO(), mockKnapsack, "")