Skip to content

Conversation

orestisfl
Copy link
Contributor

What does this PR do?

This commit includes minor developer tooling improvements:

  • Improves the checksum mismatch error message for better diagnostics.
  • Fix spurious "error closing" logs when double-closing files explicitly and with defer

Why is it important?

Checklist

  • I have read and understood the pull request guidelines of this project.
  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in ./changelog/fragments using the changelog tool
  • I have added an integration test or an E2E test

This commit includes minor developer tooling improvements:
- Improves the checksum mismatch error message for better diagnostics.
- Fix spurious "error closing" logs when double-closing files explicitely and with `defer`
@orestisfl orestisfl self-assigned this Oct 9, 2025
@orestisfl orestisfl requested a review from a team as a code owner October 9, 2025 09:07
Copy link
Member

@rubenruizdegauna rubenruizdegauna left a comment

Choose a reason for hiding this comment

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

LGTM


func closeOrLog(closer io.Closer, what string) {
err := closer.Close()
if err == nil || errors.Is(err, os.ErrClosed) {
Copy link
Member

Choose a reason for hiding this comment

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

This is a change in behavior: you are explicitly ignoring os.ErrClosed. Wouldn't it be better to figure out where we are closing the same io.Closer twice ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That can be done as well but I figured cleanliness is slightly preferred over having to set nil to the file pointers, at least for this part of the code. Other parts don't even log the Close errors.

@elasticmachine
Copy link
Collaborator

💚 Build Succeeded

History

cc @orestisfl

@pierrehilbert pierrehilbert added the Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team label Oct 9, 2025
@elasticmachine
Copy link
Collaborator

Pinging @elastic/elastic-agent-control-plane (Team:Elastic-Agent-Control-Plane)

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

Labels

backport-skip enhancement New feature or request skip-changelog Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants