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
remove logging
  • Loading branch information
kuiperda committed Sep 23, 2024
commit 4ac1c327886977ad45c2ef8535b5cf41dac65bbc
5 changes: 1 addition & 4 deletions pkg/stanza/operator/input/windows/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,7 @@ 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("Error is: ", zap.Error(err))
i.Logger().Info("windowserr is: ", zap.Error(windows.ERROR_INVALID_HANDLE))
i.Logger().Info("notopenerror is: ", zap.Error(ErrHandleNotOpen))
if i.isRemote() && (errors.Is(err, windows.ERROR_INVALID_HANDLE) || errors.Is(err, ErrHandleNotOpen)) {
if i.isRemote() && (errors.Is(err, windows.ERROR_INVALID_HANDLE) || errors.Is(err, errSubscriptionHandleNotOpen)) {
i.Logger().Info("Resubscribing, closing remote subscription")
closeErr := i.subscription.Close()
if closeErr != nil {
Expand Down
4 changes: 2 additions & 2 deletions pkg/stanza/operator/input/windows/subscription.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ func (s *Subscription) Close() error {
return nil
}

var ErrHandleNotOpen = fmt.Errorf("subscription handle is not open")
var errSubscriptionHandleNotOpen = errors.New("subscription handle is not open")

// Read will read events from the subscription.
func (s *Subscription) Read(maxReads int) ([]Event, error) {
if s.handle == 0 {
return nil, ErrHandleNotOpen
return nil, errSubscriptionHandleNotOpen
}

if maxReads < 1 {
Expand Down