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

KIP-546: Add Client Quota APIs #1119

Merged
merged 25 commits into from
Jun 15, 2023
Merged

KIP-546: Add Client Quota APIs #1119

merged 25 commits into from
Jun 15, 2023

Conversation

petedannemann
Copy link
Contributor

@petedannemann petedannemann commented Apr 19, 2023

KIP: https://cwiki.apache.org/confluence/display/KAFKA/KIP-546%3A+Add+Client+Quota+APIs+to+the+Admin+Client

API docs:
https://kafka.apache.org/protocol#The_Messages_DescribeClientQuotas

https://kafka.apache.org/protocol#The_Messages_AlterClientQuotas

I followed a similar code style to what was used for alterconfigs. Let me know if there is a better code style to use for this.

If this PR is too large to review I could split it into three pieces:

  1. Adding support for float64 data types used in Kafka's protocol (quotas appear to be the only APIs that use this data type)
  2. Add createquotas APIs
  3. Add describequotas APIs

entries := make([]alterclientquotas.Entry, len(req.Entries))

for entryIdx, entry := range req.Entries {
entities := make([]alterclientquotas.Entity, len(entry.Entities))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I followed the pattern used elsewhere where we choose not to reuse the types defined in the protocol package and create new types in the kafka package

}

responseEntries[responseEntryIdx] = AlterClientQuotaResponseQuotas{
ErrorCode: responseEntry.ErrorCode,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It looked like elsewhere we created a new errors map field in the return and grouped all the errors there instead of keeping them nested under the individual entries. Do we want that instead of what I have here?

@petedannemann petedannemann changed the title KIP-546: Add Client Quota APIs to the Admin Client KIP-546: Add Client Quota APIs Apr 20, 2023
// The quota configuration value to set, otherwise ignored if the value is to be removed.
Value float64

// Whether the quota configuration value should be removed, otherwise set.

Choose a reason for hiding this comment

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

otherwise set.

Is there a word missing at the end there ("false" maybe)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Most of these doc strings (including this one) are just quotes from the API docs. This verbiage seems common in the Kafka API docs so I think it is ok. I can change it if you feel otherwise

client, shutdown := newLocalClient()
defer shutdown()

expectedAlterResp := AlterClientQuotasResponse{

Choose a reason for hiding this comment

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

Maybe it's the standard practice to define the expected value early but it feels more logical to me just before the assert (and after the err check)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right, I just made this change.

@rhansen2 rhansen2 self-assigned this Apr 28, 2023
alterclientquotas.go Outdated Show resolved Hide resolved
type Component struct {
EntityType string `kafka:"min=v0,max=v1"`
MatchType int8 `kafka:"min=v0,max=v1"`
Match string `kafka:"min=v0,max=v1,nullable"`
Copy link
Collaborator

Choose a reason for hiding this comment

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

It looks like v1 is compact and nullable.

describeclientquotas.go Outdated Show resolved Hide resolved
@petedannemann
Copy link
Contributor Author

Thanks for the review @rhansen2! I believe I addressed your comments, let me know if there are fixes needed or other changes required!

Comment on lines 41 to 54
type Entity struct {
EntityType string `kafka:"min=v0,max=v0|min=v1,max=v1,compact"`
EntityName string `kafka:"min=v0,max=v0,nullable|min=v1,max=v1,nullable,compact"`
}

type Value struct {
Key string `kafka:"min=v0,max=v0|min=v1,max=v1,compact"`
Value float64 `kafka:"min=v0,max=v1"`
}

type ResponseQuotas struct {
Entities []Entity `kafka:"min=v0,max=v1"`
Values []Value `kafka:"min=v0,max=v1"`
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe these types also need to be marked with a tag field for v1.

@petedannemann
Copy link
Contributor Author

petedannemann commented Jun 7, 2023

@rhansen2 thanks for the review! I added tags to those types as well as similar ones in alterclientquotas

@rhansen2 rhansen2 merged commit 941002e into main Jun 15, 2023
14 checks passed
@rhansen2 rhansen2 deleted the quotas-api branch June 15, 2023 15:39
@mhmtszr mhmtszr mentioned this pull request Jul 7, 2023
This was referenced Jul 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants