Skip to content

KIP-546 (1/2): Implements describeClientQuotas() and alterClientQuotas().#8083

Merged
cmccabe merged 6 commits intoapache:trunkfrom
bdbyrne:KIP-546
Mar 15, 2020
Merged

KIP-546 (1/2): Implements describeClientQuotas() and alterClientQuotas().#8083
cmccabe merged 6 commits intoapache:trunkfrom
bdbyrne:KIP-546

Conversation

@bdbyrne
Copy link
Copy Markdown
Contributor

@bdbyrne bdbyrne commented Feb 10, 2020

Implements describeClientQuotas() and alterClientQuotas() to match current
functionality, i.e. extensible entity types and other new quotas features
like resolving quotas is not yet supported.

This is the minimal functionality necessary for KIP-500, and converts the
ConfigCommand to use the client quotas APIs. resolveClientQuotas() and the
corresponding client quotas command will be in a future PR.

Committer Checklist (excluded from commit message)

  • Verify design and implementation
  • Verify test coverage and CI build status
  • Verify documentation (including upgrade notes)

@bdbyrne bdbyrne requested a review from cmccabe February 10, 2020 22:26
@cmccabe
Copy link
Copy Markdown
Contributor

cmccabe commented Feb 20, 2020

org.apache.kafka.common.quota needs its own entry in import-control.xml

@cmccabe
Copy link
Copy Markdown
Contributor

cmccabe commented Feb 20, 2020

    public final static String USER_DEFAULT = "<default>";
    public final static String CLIENT_ID_DEFAULT = "<default>";

I don't remember discussing reserving a special string for default values. It seems like treating default as null, and then maybe printing it out in a special way in the toString, would be clearer.

What is an "unspecified entity type"? Is it the same as a default?

    private static final String MATCH_SPECIFIED = "<specified>";

Seems like we don't need angle brackets here, since the quota filter type names are ours to choose.

@bdbyrne
Copy link
Copy Markdown
Contributor Author

bdbyrne commented Mar 2, 2020

org.apache.kafka.common.quota needs its own entry in import-control.xml

Done.

    public final static String USER_DEFAULT = "<default>";
    public final static String CLIENT_ID_DEFAULT = "<default>";

I don't remember discussing reserving a special string for default values. It seems like treating default as null, and then maybe printing it out in a special way in the toString, would be clearer.

What is an "unspecified entity type"? Is it the same as a default?

    private static final String MATCH_SPECIFIED = "<specified>";

Seems like we don't need angle brackets here, since the quota filter type names are ours to choose.

The default string "" is currently defined in DynamicConfigManager$ConfigEntityType, and is used for storing the configs under ZK ("" is reserved for this purpose), so I chose to keep it the same. I can make it null, but chose to use "" to keep it consistent with the filters.

For filters, the rules are:

  • null means don't match anything (user=null means the entity type must have no user specified)
  • DEFAULT means match the default exactly (must contain user=)
  • SPECIFIED means only match if the type is specified (user= means it matches entity with {user=foo} and {user=bar, client-id=cid}, but not {client-id=cid}).

It's a bit of a mess, but unfortunately necessary. Let me know if you prefer I name things differently.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we use Optional<String> for this? Using magic string values feels messy, and will leak into the API

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'd really rather not see the double equals used with strings. I know Scala has special semantics for this, but it always looks wrong to people familiar with Java. Maybe test isEmpty instead?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If it's not supported, it shouldn't silently return incorrect data. It should throw an UnsupportedVersionException

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Need to update this JavaDoc parameter to match the new name of the function parameter.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

@cmccabe
Copy link
Copy Markdown
Contributor

cmccabe commented Mar 11, 2020

I think we can have DescribeQuotasOptions contain a "filter mode" that determines if the supplied filters are treated as "AND" or as "OR". So maybe:

enum ClientQuotaFilterMode {
  OR
  AND
}

What do you think? I think this is clearer than the boolean we had there earlier.

I don't understand QuotaFilter#matchNone. The name suggests that it doesn't match anything, but that behavior would be useless, right? What was the intention for this?

How do I filter to see just quotas on the default user (or default client id, etc.)? If we're going to use a constant for this, it should be in QuotaFilter somewhere, I think. Or we could use a factory function, I guess.

@bdbyrne
Copy link
Copy Markdown
Contributor Author

bdbyrne commented Mar 11, 2020

I think we can have DescribeQuotasOptions contain a "filter mode" that determines if the supplied filters are treated as "AND" or as "OR". So maybe:

enum ClientQuotaFilterMode {
  OR
  AND
}

What do you think? I think this is clearer than the boolean we had there earlier.

I don't understand QuotaFilter#matchNone. The name suggests that it doesn't match anything, but that behavior would be useless, right? What was the intention for this?

How do I filter to see just quotas on the default user (or default client id, etc.)? If we're going to use a constant for this, it should be in QuotaFilter somewhere, I think. Or we could use a factory function, I guess.

Perhaps think of matchNone as matchUnspecified. So maybe it should be either matchSpecified/matchUnspecified, or matchSome/matchNone. So {matchExact(user=foo), matchNone(client-id)} would return just {user=foo}, or alternatively {matchNone(client-id)} would return all users with no client ID provided.

To see quotas on default users, you'd do matchExact(user=QuoteEntity.USER_DEFAULT). I can move this to QuotaFilter, but the issue is that they're really specific to the entity type, i.e. not all entity types may contain a default value.

I don't believe AND/OR is able to handle unspecified types when they're present. OR seems useful within the same entity type, not so much across entity types. I'm not entirely sold on this approach, I'll give it some thought.

Brian Byrne added 5 commits March 11, 2020 11:58
…s().

Implements describeClientQuotas() and alterClientQuotas() to match current
functionality, i.e. extensible entity types and other new quotas features
like resolving quotas is not yet supported.

This is the minimal functionality necessary for KIP-500, and converts the
ConfigCommand to use the client quotas APIs.
@cmccabe
Copy link
Copy Markdown
Contributor

cmccabe commented Mar 15, 2020

LGTM.

Thanks, @bdbyrne. I think this slightly modified API is a lot more intuitive. Can you update the KIP to reflect the small changes here, and post to the mailing list?

@cmccabe cmccabe merged commit 227a732 into apache:trunk Mar 15, 2020
cmccabe pushed a commit that referenced this pull request Mar 16, 2020
Reviewers: Colin P. McCabe <cmccabe@apache.org>, Brian Byrne <bbyrne@confluent.io>
ijuma added a commit to confluentinc/kafka that referenced this pull request Mar 17, 2020
* apache-github/trunk: (39 commits)
  MINOR: cleanup and add tests to StateDirectoryTest (apache#8304)
  HOTFIX: StateDirectoryTest should use Set instead of List (apache#8305)
  MINOR: Fix build and JavaDoc warnings (apache#8291)
  MINOR: Fix kafka.server.RequestQuotaTest missing new ApiKeys. (apache#8302)
  KAFKA-9712: Catch and handle exception thrown by reflections scanner (apache#8289)
  KAFKA-9670; Reduce allocations in Metadata Response preparation (apache#8236)
  MINOR: fix Scala 2.13 build error introduced in apache#8083 (apache#8301)
  MINOR: enforce non-negative invariant for checkpointed offsets (apache#8297)
  MINOR: comment apikey types in generated switch (apache#8201)
  MINOR: Fix typo in CreateTopicsResponse.json (apache#8300)
  KIP-546: Implement describeClientQuotas and alterClientQuotas. (apache#8083)
  KAFKA-6647: Do note delete the lock file while holding the lock (apache#8267)
  KAFKA-9677: Fix consumer fetch with small consume bandwidth quotas (apache#8290)
  KAFKA-9533: Fix JavaDocs of KStream.transformValues (apache#8298)
  MINOR: reuse pseudo-topic in FKJoin (apache#8296)
  KAFKA-6145: Pt 2. Include offset sums in subscription (apache#8246)
  KAFKA-9714; Eliminate unused reference to IBP in `TransactionStateManager` (apache#8293)
  KAFKA-9718; Don't log passwords for AlterConfigs in request logs (apache#8294)
  KAFKA-8768: DeleteRecords request/response automated protocol (apache#7957)
  KAFKA-9685: Solve Set concatenation perf issue in AclAuthorizer
  ...
gitlw added a commit to linkedin/kafka that referenced this pull request Sep 9, 2021
…d alterClientQuotas. (apache#8083)

Reviewers: Colin P. McCabe <cmccabe@apache.org>
gitlw pushed a commit to linkedin/kafka that referenced this pull request Sep 9, 2021
…ed in apache#8083 (apache#8301)

Reviewers: Colin P. McCabe <cmccabe@apache.org>, Brian Byrne <bbyrne@confluent.io>
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.

2 participants