Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pkg/stanza] Windows input operator should resubscribe when remote host restarts #35175

Merged
Merged
Prev Previous commit
Next Next commit
check if connection is remote before resubscribing to remote
  • Loading branch information
kuiperda committed Sep 23, 2024
commit 269c69a71a8fe7e767888c3e681343e47081fd8c
16 changes: 9 additions & 7 deletions pkg/stanza/operator/input/windows/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,14 +216,16 @@ func (i *Input) read(ctx context.Context) int {
events, err := i.subscription.Read(i.maxReads)
if err != nil {
i.Logger().Error("Failed to read events from subscription", zap.Error(err))
i.Logger().Info("Closing subscription")
closeErr := i.subscription.Close()
if closeErr != nil {
i.Logger().Error("Failed to close subscription", zap.Error(closeErr))
return 0
if i.isRemote() {
i.Logger().Info("Resubscribing, closing subscription")
closeErr := i.subscription.Close()
if closeErr != nil {
i.Logger().Error("Failed to close subscription", zap.Error(closeErr))
return 0
}
i.Logger().Info("Resubscribing, creating subscription")
i.subscription = NewRemoteSubscription(i.remote.Server)
}
i.Logger().Info("Resubscribing")
i.subscription = NewRemoteSubscription(i.remote.Server)
return 0
}

Expand Down