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] Stop readerFactory from returning an error when creating an unsafeReader #12767

Merged
merged 1 commit into from
Jul 28, 2022

Conversation

aboguszewski-sumo
Copy link
Member

Description:
The method unsafeReader() of the readerBuilder no longer returns errors when the parameter isBeginning is set to false. This caused the filelog receiver to crash when the collector was restarted and the parameter start_at was set to end (which was also the default value).

Link to tracking Issue:
Fixes #12766

Testing:
Manual testing against the test data mentioned in the issue.

… an unsafeReader

Because the unsafeReader is not linked to any file, it caused an error when the readerBuilder tried to set its offset to the end of the file. Because the unsafeReader is later initialized with other data, we can simply ignore setting the offset here, because it will be overwritten anyway.
Copy link
Member

@djaglowski djaglowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for reporting this and submitting the fix as well.

I would like to rework the implementation, but this issue is urgent. I've manually verified the issue and tested the fix, so I will merge this now and submit a follow up PR with this suggestion and some test cases.

Comment on lines +131 to +132
// unsafeReader has the file set to nil, so don't try emending its offset.
if !b.fromBeginning && !b.isUnsafe {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically, we don't need the additional variable and associated code, and could just move this block into the if b.file != nil condition above. I think the comment you've added would be sufficient to explain why it is located there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[pkg/stanza] Creating unsafeReader returns an error when initialised with fromBeginning set to false
3 participants