Skip to content

Commit 60a298b

Browse files
committed
consistency changes
1 parent 283f772 commit 60a298b

File tree

4 files changed

+8
-10
lines changed

4 files changed

+8
-10
lines changed

.chloggen/windows-events-err-1734.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ change_type: bug_fix
77
component: pkg/stanza
88

99
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10-
note: Adds dynamic batching whenever err no 1734 (invalid bounds) has occured.
10+
note: Add retries when calls to retrieve Windows event via `EvtNext` fail with error RPC_S_INVALID_BOUND (1734).
1111

1212
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
1313
issues: [38149]
@@ -16,8 +16,8 @@ issues: [38149]
1616
# These lines will be padded with 2 spaces and then inserted directly into the document.
1717
# Use pipe (|) for multiline entries.
1818
subtext: |
19-
Whever large events were read in by the windows event log receiver / stanza input operator for windows
20-
There would be an Invalid array bounds error that popped up (1734). This can be solved by reducing the batch size / maxreads.
19+
Whenever large events were read in by the windows event log receiver / stanza input operator for windows,
20+
The collector would fail with error RPC_S_INVALID_BOUND (1734). This can be solved by reducing max reads and retrying.
2121
# If your change doesn't affect end users or the exported elements of any package,
2222
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
2323
# Optional: The change log or logs in which this entry should be included.

pkg/stanza/operator/input/windows/input.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ type Input struct {
4141
remoteSessionHandle windows.Handle
4242
startRemoteSession func() error
4343
processEvent func(context.Context, Event) error
44-
logger *zap.Logger
4544
}
4645

4746
// newInput creates a new Input operator.
@@ -202,7 +201,7 @@ func (i *Input) read(ctx context.Context) {
202201
events, err := i.subscription.Read(i.currentMaxReads)
203202
if errors.Is(err, ErrBatchSizeReduced) {
204203
i.currentMaxReads = max(i.currentMaxReads/2, 1)
205-
i.Logger().Warn("Encountered RPC_S_INVALID_BOUND, reducing batch size", zap.Int("current batch size", i.currentMaxReads), zap.Int("original batch size", i.maxReads))
204+
i.Logger().Debug("Encountered RPC_S_INVALID_BOUND, reducing batch size", zap.Int("current batch size", i.currentMaxReads), zap.Int("original batch size", i.maxReads))
206205
} else if err != nil {
207206
i.Logger().Error("Failed to read events from subscription", zap.Error(err))
208207
if i.isRemote() && (errors.Is(err, windows.ERROR_INVALID_HANDLE) || errors.Is(err, errSubscriptionHandleNotOpen)) {
@@ -231,12 +230,12 @@ func (i *Input) read(ctx context.Context) {
231230

232231
for n, event := range events {
233232
if err := i.processEvent(ctx, event); err != nil {
234-
i.logger.Error("process event", zap.Error(err))
233+
i.Logger().Error("process event", zap.Error(err))
235234
}
236235
if len(events) == n+1 {
237236
i.updateBookmarkOffset(ctx, event)
238237
if err := i.subscription.bookmark.Update(event); err != nil {
239-
i.logger.Error("Failed to update bookmark from event", zap.Error(err))
238+
i.Logger().Error("Failed to update bookmark from event", zap.Error(err))
240239
}
241240
}
242241
event.Close()

pkg/stanza/operator/input/windows/input_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ func TestInputRead_RPCInvalidBound(t *testing.T) {
175175
}()
176176

177177
// Create a logger with an observer for testing log output
178-
core, logs := observer.New(zap.WarnLevel)
178+
core, logs := observer.New(zap.DebugLevel)
179179
logger := zap.New(core)
180180

181181
// Create input instance with mocked dependencies
@@ -186,7 +186,6 @@ func TestInputRead_RPCInvalidBound(t *testing.T) {
186186
// Set up test values
187187
input.maxReads = 100
188188
input.currentMaxReads = 100
189-
input.logger = logger
190189

191190
// Set up subscription with valid handle and enough info to reopen
192191
input.subscription = Subscription{

pkg/stanza/operator/input/windows/subscription.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ func (s *Subscription) readWithRetry(maxReads int) ([]Event, error) {
112112
return nil, nil
113113
}
114114

115-
if err != nil && errors.Is(err, windows.RPC_S_INVALID_BOUND) {
115+
if errors.Is(err, windows.RPC_S_INVALID_BOUND) {
116116
// close current subscription
117117
if closeErr := s.Close(); closeErr != nil {
118118
return nil, fmt.Errorf("failed to close subscription during recovery: %w", closeErr)

0 commit comments

Comments
 (0)