-
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
fix: AdminClient | CreateACLs | check for error in response, return error if needed #2185
fix: AdminClient | CreateACLs | check for error in response, return error if needed #2185
Conversation
broker.go
Outdated
for _, res := range response.AclCreationResponses { | ||
if !errors.Is(res.Err, ErrNoError) { | ||
Logger.Printf("Failed creating ACL: %s\n", res.Err.Error()) | ||
return response, res.Err | ||
} | ||
} |
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.
Thanks for spotting this. Rather than returning the first error, should we be returning the collection of errors?
e.g.,
errs := make([]error, 0)
for _, res := range response.AclCreationResponses {
if !errors.Is(res.Err, ErrNoError) {
errs = append(errs, err)
}
}
if len(errs) > 0 {
return Wrap(ErrCreateACLs, errs...)
}
with errors.go
// ErrCreateACLs is the type of error returned when ACL creation failed
var ErrCreateACLs = errors.New("kafka server: failed to create one or more ACLs")
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.
Done 👍
Could this explain #2167? |
@nkostoulas yes I believe it will |
I added a test |
@dnwe, I would appreciate a merge or a feedback, since we want to use the upstream instead of a branch |
@omris94 sure, changes look good to me so I’m happy to review and merge. We have a few more things I’d like to see go in before we’d cut a new version number, but I guess you’re happy to track via a commit in main until then? |
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.
@omris94 great catch this one, and thank you for your first contribution!
While calling to CreateACLs, the errors returned from the Kafka broker are ignored. ACL creation can fail but the function returns no error.
This PR makes the function return an error if one or more AclCreationResponse.Err is not ErrNoError.