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

*: Fix issue #7550 - Check correct error when opening rule files in tools #7552

Merged

Conversation

NishantBansal2003
Copy link
Contributor

@NishantBansal2003 NishantBansal2003 commented Jul 16, 2024

  • I added CHANGELOG entry for this change.
  • Change is not relevant to the end user.

Changes

Fixes #7550
There is a bug in this part of the code. If there is an issue with opening the file through os.Open(), we will not be able to obtain exact error logs for debugging. It should return error logs in case there is an issue with os.Open().
So, I fixed this bug and added test coverage.

Verification

Run the Tests: Execute the following command to run the tests and verify that the bug has been fixed and the new tests are functioning correctly:

go test -v ./cmd/thanos

Check Test Results: Ensure that all tests pass and that there are no error messages related to the issue with os.Open()

@NishantBansal2003
Copy link
Contributor Author

NishantBansal2003 commented Jul 16, 2024

Hey, Please review the changes and suggest potential improvements. Thanks!

@NishantBansal2003 NishantBansal2003 force-pushed the bugfix/fix-and-test-tools branch from e7e6861 to 2f7095b Compare July 17, 2024 08:57
@NishantBansal2003
Copy link
Contributor Author

Hey @saswatamcode, Could you please review this PR and suggest potential improvements? Thank you!

saswatamcode
saswatamcode previously approved these changes Jul 20, 2024
Copy link
Member

@saswatamcode saswatamcode left a comment

Choose a reason for hiding this comment

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

Thanks!
But I think PR and issue title are a bit misleading. Maybe should be something like, "Check correct error when opening rule files in tools"?

cmd/thanos/tools.go Outdated Show resolved Hide resolved
@NishantBansal2003 NishantBansal2003 changed the title *: Fix issue #7550 - Bug fix and complete test coverage for tools.go *: Fix issue #7550 - Check correct error when opening rule files in tools Jul 20, 2024
…s.go

Signed-off-by: Nishant Bansal <nishant.bansal.mec21@iitbhu.ac.in>
@@ -55,7 +55,6 @@ func checkRulesFiles(logger log.Logger, patterns *[]string) error {
if err != nil || matches == nil {
err = errors.New("matching file not found")
level.Error(logger).Log("result", "FAILED", "error", err)
level.Info(logger).Log()
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to remove this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These are just empty logs, Its output is - level=info, So I removed all level.Info(logger).Log()

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it might be intended to leave some spaces between lines.

Copy link
Contributor Author

@NishantBansal2003 NishantBansal2003 Jul 20, 2024

Choose a reason for hiding this comment

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

Ok, Should I reintroduce all instances of level.Info(logger).Log() throughout the tools.go, or only in this specific part(line 58) of the code?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't have strong preference. I am ok either way to keep them or remove them.

cmd/thanos/tools.go Show resolved Hide resolved
@NishantBansal2003
Copy link
Contributor Author

Hey @saswatamcode,
I removed all instances of empty logs (level.Info(logger).Log()) in the tools. However, if there's a need to bring back any specific ones, please let me know.

@saswatamcode saswatamcode merged commit 5765d3c into thanos-io:main Jul 21, 2024
20 checks passed
jnyi pushed a commit to jnyi/thanos that referenced this pull request Oct 17, 2024
…s.go (thanos-io#7552)

Signed-off-by: Nishant Bansal <nishant.bansal.mec21@iitbhu.ac.in>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Check correct error when opening rule files in tools
3 participants