-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
feat: make ErrOutOfBrokers
wrap the underlying error that prevented connections to the brokers
#2131
Conversation
@k-wall Thanks for your contribution! Looks like there are some linter failures on Go 1.17, could you please take a look? |
c00e2ee
to
68ced2a
Compare
@bai thanks for looking. I'm not certain what the output from the Github Action is trying to tell me. I think you are referring to these errors in the output.
However, when I run the tooling locally against my branch, I see a different set of errors. My local tools:
and the output I get when I run the CI command line locally:
Can you give me a pointer to help diagnose the problem or tell me how to get verbose output from CI? My best guess is that the tool believes that the new |
@k-wall the functional tests are gated behind a build flag so to lint the full source code directly you need to set that flag before running golangci-lint (or you can use the makefile version which does it for you via
These files are just missing the "errors" import entirely — you can fix them with |
I've made those changes, rebased the commits and force pushed to get a build through — I'll go ahead and review now |
ErrOutOfBrokers
wrap the underlying error that prevented connections to the brokers
admin.go
Outdated
@@ -185,11 +185,11 @@ func (ca *clusterAdmin) refreshController() (*Broker, error) { | |||
func isErrNoController(err error) bool { | |||
switch e := err.(type) { | |||
case *TopicError: | |||
return e.Err == ErrNotController | |||
return errors.Is(e.Err, ErrNotController) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@k-wall do we need to also change the type switches to if errors.As(err, ...)
as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm having second thoughts about the wisdom of the errors.Is
refactor within the implementation. My intent was to help make clear that API now requires the sarama user must use errors.Is
etc. I thought adopting that within the implementation that would reinforce the practice. There's a couple of things that don't sit well:
- there a runtime cost to errors.Is (reflection). - kafka is supposed to be high performance - and this detracts from that.
- expressions involving
errors.IsI(err, NoError)
just seem weird. I worry about aNoError
getting wrapped causing a weird bug. - it's turned out to be more intrusive than I anticipated.
I thinking of an alternative that limit errors.Is use on the public API boundaries (i.e the interfaces). I think this might just boil down to the tests using errors.Is
and new documentation on Client, AsyncProducer etc. The implementation would be reverted back.
Thanks again for the time you are giving me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dnwe hi - my last message wasn't too clear, I was trying to ask WDYT to the suggestion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the end, retaining the current errors.Is/As and refactoring the type switches seemed like the right approach. I've also enabled the errorlint
linter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@k-wall thanks! will take a look
Thanks for the feedback, I'll update the PR based in the feedback. I'd also like to ask about the behaviour of Is there a reason why it error contract is different? I am wondering if it should actually return ErrOutOfBrokers, and with this change, wrap the errors from the brokers? |
@k-wall yes I agree, it would make sense for the overall error |
f255d70
to
cbc3918
Compare
@k-wall thanks for all your hard work on this — merged 🎉 |
This complies with changes from IBM/sarama#2131. This change ought to have been made when the upgrade to Sarama 1.33 was made, but it was overlooked. Its ommision hasn't caused a functional problem.
This complies with changes from IBM/sarama#2131. This change ought to have been made when the upgrade to Sarama 1.33 was made, but it was overlooked. Its ommision hasn't caused a functional problem. Signed-off-by: kwall <[email protected]>
This complies with changes from IBM/sarama#2131. This change ought to have been made when the upgrade to Sarama 1.33 was made, but it was overlooked. Its ommision hasn't caused a functional problem. Signed-off-by: kwall <[email protected]>
This complies with changes from IBM/sarama#2131. This change ought to have been made when the upgrade to Sarama 1.33 was made, but it was overlooked. Its ommision hasn't caused a functional problem. Signed-off-by: kwall <[email protected]>
* Upgrade go Signed-off-by: kwall <[email protected]> * use errors.Is when testing sarama errors This complies with changes from IBM/sarama#2131. This change ought to have been made when the upgrade to Sarama 1.33 was made, but it was overlooked. Its ommision hasn't caused a functional problem. Signed-off-by: kwall <[email protected]> * upgrade sarama to 1.37.2 Signed-off-by: kwall <[email protected]> * fix test/e2e_test.go:50:5: call to (*T).Fatal from a non-test goroutine reported by go vet await canary readiness before starting tests (avoid spurious CI failure). Signed-off-by: kwall <[email protected]> Signed-off-by: kwall <[email protected]>
With this change, the user of Sarama is required to use Go 1.13's
errors.Is
etc (rather then==
) when forming conditionals returned by this library.