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

[cmd/opampsupervisor] Fix early exits not shutting down client/server in bootstrapping #31944

Conversation

BinaryFissionGames
Copy link
Contributor

Description:

  • Fix early exits not shutting down client/server in bootstrapping

Link to tracking Issue: Closes #31943

Testing:
I tested manually adding errors into the code. There isn't a good, consistent way to add e.g. the timeout error as-is.

@BinaryFissionGames BinaryFissionGames force-pushed the fix/opamp-supervisor-bootstrap-error-shutdown branch from 9f85771 to 1d9167f Compare March 27, 2024 13:03
@BinaryFissionGames BinaryFissionGames marked this pull request as ready for review March 27, 2024 13:03
@BinaryFissionGames BinaryFissionGames requested a review from a team as a code owner March 27, 2024 13:03
Copy link
Member

@crobert-1 crobert-1 left a comment

Choose a reason for hiding this comment

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

Just a couple wording nits, feel free to ignore if they're not helpful. Looks good!

cmd/opampsupervisor/supervisor/supervisor.go Outdated Show resolved Hide resolved
cmd/opampsupervisor/supervisor/supervisor.go Outdated Show resolved Hide resolved
@BinaryFissionGames BinaryFissionGames force-pushed the fix/opamp-supervisor-bootstrap-error-shutdown branch 2 times, most recently from 2666090 to 523bf0d Compare April 3, 2024 19:41
@BinaryFissionGames BinaryFissionGames force-pushed the fix/opamp-supervisor-bootstrap-error-shutdown branch from 523bf0d to 8f2b374 Compare April 10, 2024 18:41
@BinaryFissionGames BinaryFissionGames force-pushed the fix/opamp-supervisor-bootstrap-error-shutdown branch from 8f2b374 to 2f1c0d2 Compare April 15, 2024 14:48
Copy link
Contributor

@evan-bradley evan-bradley left a comment

Choose a reason for hiding this comment

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

Thanks for submitting a fix for this, and sorry for the long delay. Could you explain the flow of what is returned to me? If we execute return errors.New("..."), is err set to the return value in the deferred functions?

@BinaryFissionGames
Copy link
Contributor Author

Thanks for submitting a fix for this, and sorry for the long delay. Could you explain the flow of what is returned to me? If we execute return errors.New("..."), is err set to the return value in the deferred functions?

Yes, that's exactly right. In the defer statements, err will be the value that will be returned (the errors.New value). Then, the defers can further modify that value in cases where it has it's own error.

Here's an example: https://go.dev/play/p/hT6HZSK62NH

@evan-bradley
Copy link
Contributor

Yes, that's exactly right. In the defer statements, err will be the value that will be returned (the errors.New value). Then, the defers can further modify that value in cases where it has its own error.

Great, thank you. That's straightforward, just hadn't seen that pattern before.

@evan-bradley evan-bradley merged commit 97db72a into open-telemetry:main Apr 16, 2024
170 checks passed
@github-actions github-actions bot added this to the next release milestone Apr 16, 2024
@djaglowski djaglowski deleted the fix/opamp-supervisor-bootstrap-error-shutdown branch April 16, 2024 14:42
rimitchell pushed a commit to rimitchell/opentelemetry-collector-contrib that referenced this pull request May 8, 2024
… in bootstrapping (open-telemetry#31944)

**Description:**
* Fix early exits not shutting down client/server in bootstrapping

**Link to tracking Issue:** Closes open-telemetry#31943

**Testing:**
I tested manually adding errors into the code. There isn't a good,
consistent way to add e.g. the timeout error as-is.

---------

Co-authored-by: Daniel Jaglowski <[email protected]>
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.

[cmd/opampsupervisor] Errors during bootstrapping will fail to shut down collector
5 participants