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

[chore][pkg/stanza] Unexport reader's file name field #27434

Conversation

djaglowski
Copy link
Member

Incremental step towards decoupling the Reader struct.

This also clarifies and corrects the behavior of the ValidateOrClose function.

@djaglowski djaglowski marked this pull request as ready for review October 4, 2023 21:04
@djaglowski djaglowski requested a review from a team as a code owner October 4, 2023 21:04
@djaglowski djaglowski force-pushed the pkg-stanza-reader-unexporter-filename branch from 6809e7a to c34e270 Compare October 4, 2023 21:36
if !oldReader.ValidateFingerprint() {
continue OUTER
}
if !newReader.NameEquals(oldReader) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this a change of behavior?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think so. The equal check is moved into the function.

The inversion of the condition is met with a complimentary inversion of how we react to it.

Copy link
Member Author

Choose a reason for hiding this comment

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

You're right, this was a change. It should only continue the inner loop if the file names do not match. I opened #27454 to make the change separately. I'll plan on rebasing this PR.

return true
}
r.logger.Debugw("Closing truncated file", zap.String(attrs.LogFileName, r.fileName))
r.Close()
Copy link
Contributor

Choose a reason for hiding this comment

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

this is not a rename right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Right, not just a rename. It also corrects the behavior. It was previously described in the function description that this should happen but it wasn't happening yet. I mentioned the correction in the PR description though I'm not sure this is a user visible change in any case.

Copy link
Member Author

Choose a reason for hiding this comment

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

I realized you may have been asking about whether this could be a renamed file. If so:

I don't think we can ascertain whether the file has been renamed. We know the file name as it was when it was first opened (because we called os.Open(filename)), but there is no way to refresh the name from the information we have.

@djaglowski djaglowski force-pushed the pkg-stanza-reader-unexporter-filename branch from c34e270 to cd2bb7e Compare October 4, 2023 23:47
@djaglowski
Copy link
Member Author

@atoulme, I split out the changes to the validation function into a dedicated PR #27453

@djaglowski
Copy link
Member Author

Converted back to draft until #27453 and #27454 are merged

djaglowski added a commit that referenced this pull request Oct 6, 2023
@djaglowski djaglowski force-pushed the pkg-stanza-reader-unexporter-filename branch from 6440bb6 to 79d964c Compare October 6, 2023 15:16
@djaglowski djaglowski force-pushed the pkg-stanza-reader-unexporter-filename branch from 79d964c to a586925 Compare October 6, 2023 20:13
jorgeancal pushed a commit to jorgeancal/opentelemetry-collector-contrib that referenced this pull request Oct 9, 2023
jorgeancal pushed a commit to jorgeancal/opentelemetry-collector-contrib that referenced this pull request Oct 9, 2023
@djaglowski djaglowski marked this pull request as ready for review October 11, 2023 14:01
@djaglowski djaglowski merged commit 813fdb4 into open-telemetry:main Oct 11, 2023
85 checks passed
@djaglowski djaglowski deleted the pkg-stanza-reader-unexporter-filename branch October 11, 2023 17:05
@github-actions github-actions bot added this to the next release milestone Oct 11, 2023
JaredTan95 pushed a commit to openinsight-proj/opentelemetry-collector-contrib that referenced this pull request Oct 18, 2023
…#27434)

Incremental step towards decoupling the Reader struct.

This also clarifies and corrects the behavior of the `ValidateOrClose`
function.
jmsnll pushed a commit to jmsnll/opentelemetry-collector-contrib that referenced this pull request Nov 12, 2023
jmsnll pushed a commit to jmsnll/opentelemetry-collector-contrib that referenced this pull request Nov 12, 2023
jmsnll pushed a commit to jmsnll/opentelemetry-collector-contrib that referenced this pull request Nov 12, 2023
…#27434)

Incremental step towards decoupling the Reader struct.

This also clarifies and corrects the behavior of the `ValidateOrClose`
function.
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.

None yet

4 participants