-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Add Quotas API to Kafka CR and upgrade Strimzi Quotas Plugin to 0.3.1 #9895
base: main
Are you sure you want to change the base?
Conversation
692d830
to
97aa69f
Compare
97aa69f
to
3b5d419
Compare
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.
You should also go through the PR checklist to see what to do as part of the Pr such as update the CHANGELOG. You should also at least remove the old invalid docs from the documentation.
api/src/main/java/io/strimzi/api/kafka/model/kafka/quotas/QuotasPlugin.java
Outdated
Show resolved
Hide resolved
api/src/main/java/io/strimzi/api/kafka/model/kafka/quotas/QuotasPluginKafka.java
Outdated
Show resolved
Hide resolved
...perator/src/main/java/io/strimzi/operator/cluster/model/KafkaBrokerConfigurationBuilder.java
Outdated
Show resolved
Hide resolved
...perator/src/main/java/io/strimzi/operator/cluster/model/KafkaBrokerConfigurationBuilder.java
Outdated
Show resolved
Hide resolved
...erator/src/main/java/io/strimzi/operator/cluster/model/quotas/QuotasPluginConfiguration.java
Outdated
Show resolved
Hide resolved
cluster-operator/src/main/java/io/strimzi/operator/cluster/model/quotas/QuotasPluginUtils.java
Outdated
Show resolved
Hide resolved
...er-operator/src/main/java/io/strimzi/operator/cluster/operator/assembly/KafkaReconciler.java
Outdated
Show resolved
Hide resolved
...er-operator/src/main/java/io/strimzi/operator/cluster/operator/assembly/KafkaReconciler.java
Outdated
Show resolved
Hide resolved
...er-operator/src/main/java/io/strimzi/operator/cluster/operator/assembly/KafkaReconciler.java
Outdated
Show resolved
Hide resolved
...er-operator/src/main/java/io/strimzi/operator/cluster/operator/assembly/KafkaReconciler.java
Outdated
Show resolved
Hide resolved
api/src/main/java/io/strimzi/api/kafka/model/kafka/quotas/QuotasPluginStrimzi.java
Show resolved
Hide resolved
api/src/main/java/io/strimzi/api/kafka/model/kafka/quotas/QuotasPluginStrimzi.java
Outdated
Show resolved
Hide resolved
api/src/main/java/io/strimzi/api/kafka/model/kafka/quotas/QuotasPluginStrimzi.java
Outdated
Show resolved
Hide resolved
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.
Hi @im-konge, thanks for working on this. Left some comments.
Once this PR is merged, I think we need to also remove this warning.
api/src/main/java/io/strimzi/api/kafka/model/kafka/quotas/QuotasPlugin.java
Show resolved
Hide resolved
api/src/main/java/io/strimzi/api/kafka/model/kafka/quotas/QuotasPluginKafka.java
Outdated
Show resolved
Hide resolved
api/src/main/java/io/strimzi/api/kafka/model/kafka/quotas/QuotasPluginStrimzi.java
Outdated
Show resolved
Hide resolved
api/src/main/java/io/strimzi/api/kafka/model/kafka/quotas/QuotasPluginStrimzi.java
Outdated
Show resolved
Hide resolved
...perator/src/main/java/io/strimzi/operator/cluster/model/KafkaBrokerConfigurationBuilder.java
Show resolved
Hide resolved
...tor/src/test/java/io/strimzi/operator/cluster/model/KafkaBrokerConfigurationBuilderTest.java
Outdated
Show resolved
Hide resolved
...er-operator/src/main/java/io/strimzi/operator/cluster/operator/assembly/KafkaReconciler.java
Outdated
Show resolved
Hide resolved
...er-operator/src/main/java/io/strimzi/operator/cluster/operator/assembly/KafkaReconciler.java
Outdated
Show resolved
Hide resolved
cluster-operator/src/main/java/io/strimzi/operator/cluster/model/KafkaCluster.java
Outdated
Show resolved
Hide resolved
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.
Looking good! I left a couple of suggestions.
As discussed, there will be related doc that needs updating, but should probably be left to a separate pr.
api/src/main/java/io/strimzi/api/kafka/model/kafka/KafkaClusterSpec.java
Outdated
Show resolved
Hide resolved
api/src/main/java/io/strimzi/api/kafka/model/kafka/quotas/QuotasPluginKafka.java
Outdated
Show resolved
Hide resolved
api/src/main/java/io/strimzi/api/kafka/model/kafka/quotas/QuotasPluginStrimzi.java
Outdated
Show resolved
Hide resolved
api/src/main/java/io/strimzi/api/kafka/model/kafka/quotas/QuotasPluginStrimzi.java
Outdated
Show resolved
Hide resolved
@PaulRMellor thanks for reviewing the descriptions, I updated the section mentioning Kafka Static Quota plugin, to match the 0.3.0 version + the API changes. Could you please review that as well? Thanks! (I can create a follow-up docs PR that will mention the default user quotas, I just wanted to update in this one the parts that will not be correct after this change) |
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.
LGTM. Great work!
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.
additional changes look good. Just a couple of suggestions
api/src/main/java/io/strimzi/api/kafka/model/kafka/quotas/QuotasPlugin.java
Outdated
Show resolved
Hide resolved
api/src/main/java/io/strimzi/api/kafka/model/kafka/quotas/QuotasPluginStrimzi.java
Outdated
Show resolved
Hide resolved
...perator/src/main/java/io/strimzi/operator/cluster/model/KafkaBrokerConfigurationBuilder.java
Outdated
Show resolved
Hide resolved
cluster-operator/src/main/java/io/strimzi/operator/cluster/model/KafkaCluster.java
Outdated
Show resolved
Hide resolved
...-operator/src/main/java/io/strimzi/operator/cluster/operator/assembly/QuotasPluginUtils.java
Outdated
Show resolved
Hide resolved
...er-operator/src/main/java/io/strimzi/operator/cluster/operator/assembly/KafkaReconciler.java
Outdated
Show resolved
Hide resolved
...-operator/src/main/java/io/strimzi/operator/cluster/operator/assembly/QuotasPluginUtils.java
Outdated
Show resolved
Hide resolved
...er-operator/src/main/java/io/strimzi/operator/cluster/operator/assembly/KafkaReconciler.java
Outdated
Show resolved
Hide resolved
cluster-operator/src/test/java/io/strimzi/operator/cluster/ResourceUtils.java
Outdated
Show resolved
Hide resolved
e5ab858
to
acac770
Compare
@scholzj @ppatierno the PR is updated with the new version of Strimzi Quotas plugin (0.3.1), the comments should be now resolved and I updated also the ST for the quotas plugin, to reflect the changes from this PR. When you have time, could you please have another look? Thanks :) |
CHANGELOG.md
Outdated
### Changes, deprecations and removals | ||
* Usage of Strimzi Quotas plugin version 0.2.0 is not supported and from Strimzi 0.42.0, the plugin is configured | ||
in `.spec.kafka.quotas` section - the configuration of the plugin inside `.spec.kafka.config` should be removed. |
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.
- You should have space between the title and the list
- I think this is a bit misleading as at the same time the plugin changed significantly. So I would warn against that rather than just say that the configuration moved.
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 think that it's useful to mention that the plugin is not configured in the .spec.kafka.config
, but I agree that the plugin changed significantly. So maybe something like:
Usage of Strimzi Quotas plugin version 0.2.0 is not supported, the plugin was updated to 0.3.1 and changed significantly. Additionally, from Strimzi 0.42.0 the plugin should be configured in `.spec.kafka.quotas` section - the configuration of the plugin inside `.spec.kafka.config` should be removed.
?
api/src/main/java/io/strimzi/api/kafka/model/kafka/KafkaClusterSpec.java
Outdated
Show resolved
Hide resolved
api/src/main/java/io/strimzi/api/kafka/model/kafka/quotas/QuotasPluginStrimzi.java
Outdated
Show resolved
Hide resolved
@Description("A quota on the maximum bytes per-second that each client group can publish to a broker before " + | ||
"the clients in the group are throttled. Defined on a per-broker basis.") |
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.
Is this the case? Isn't it overall throughput per broker? Per cluster?
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.
Yeah this description is wrong, it should be byte-rate for all of the clients per cluster (I think).
So something like
A total quota limiting byte-rate for clients, independent on their number, that produce to a cluster, defined on a per-cluster basis. The limitation depends on the clients produce speed - in case that clients are producing messages as fast as possible, the limitation will be equal for all. In other case when one is producing at specific rate, the other one is limited by the remainder of the difference between the specified byte-rate and the speed of the first.
but I guess it's too long for a description 😄
Same applies for the fetch quota
WDYT @scholzj ?
...r/src/main/java/io/strimzi/operator/cluster/operator/assembly/DefaultKafkaQuotasManager.java
Outdated
Show resolved
Hide resolved
...r/src/main/java/io/strimzi/operator/cluster/operator/assembly/DefaultKafkaQuotasManager.java
Outdated
Show resolved
Hide resolved
Map<String, Double> currentQuotas = kafkaAdmin.describeClientQuotas(ClientQuotaFilter.containsOnly(Collections.singletonList(ClientQuotaFilterComponent.ofDefaultEntity(ClientQuotaEntity.USER)))) | ||
.entities() | ||
.get() | ||
.get(DEFAULT_USER_ENTITY); |
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.
This sounds like blocking operation. You need to handle this properly as async code.
cluster-operator/src/test/java/io/strimzi/operator/cluster/ResourceUtils.java
Outdated
Show resolved
Hide resolved
...tor/src/test/java/io/strimzi/operator/cluster/model/KafkaBrokerConfigurationBuilderTest.java
Show resolved
Hide resolved
...perator/src/main/java/io/strimzi/operator/cluster/model/KafkaBrokerConfigurationBuilder.java
Show resolved
Hide resolved
cluster-operator/src/main/java/io/strimzi/operator/cluster/model/KafkaCluster.java
Outdated
Show resolved
Hide resolved
...r/src/main/java/io/strimzi/operator/cluster/operator/assembly/DefaultKafkaQuotasManager.java
Outdated
Show resolved
Hide resolved
* | ||
* @return Future which completes when the default quotas are configured | ||
*/ | ||
protected Future<Void> defaultKafkaQuotas() { |
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.
so this method is calling something related to the specific Kafka quotas plugin (by using the DefaultKafkaQuotasManager
) but then internally it's checking if the quota plugin is really an instance of the QuotasPluginKafka
. I would move the check here and not inside so avoiding the call at all? It would make clear in the reconciliation code that you are going to configure default user quotas but only if the Kafka quotas plugin is used, or?
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.
Don't you need to delete the quotas if they are not set in the Kafka CR?
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.
Yes as Jakub mentioned, it is there for un-setting the default quotas.
That's for the scenario when we had configuration for the QuotasPluginKafka
in previous spec, the default quotas were set in Kafka, and now we want to move to QuotasPluginStrimzi
or null
. It's not about checking if the actual spec is QuotasPluginKafka
type or not.
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.
My mental model was about expecting a call to a quotas manager which is able to configure the right quotas plugin (if it's Kafka or Strimzi) and not a dedicated call in the reconciler using a dedicated class like the DefaultKafkaQuotasManager which is just about the Kafka plugin (so configuring default quotas or removing them).
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.
Strimzi quotas plugin is configured in the broker configuration and this is named defaultKafkaQuotas
, so it should cover just the Kafka quotas plugin.
From the code I saw that it's both configured on different places and I think it would not be trivial to have something like configureQuotas()
which would then, based on plugin type, configure the broker configuration for Strimzi plugin or create/alter the default quotas in Kafka using Kafka Admin client.
But maybe I'm wrong
Signed-off-by: Lukas Kral <lukywill16@gmail.com> fixups and tests Signed-off-by: Lukas Kral <lukywill16@gmail.com> few more changes, comments, changes to the QuotasST Signed-off-by: Lukas Kral <lukywill16@gmail.com> add one more check and OneOf to the Strimzi quota plugin fields Signed-off-by: Lukas Kral <lukywill16@gmail.com> changes after rebase Signed-off-by: Lukas Kral <lukywill16@gmail.com> comments Signed-off-by: Lukas Kral <lukywill16@gmail.com> crd install Signed-off-by: Lukas Kral <lukywill16@gmail.com> fix spotbugs Signed-off-by: Lukas Kral <lukywill16@gmail.com> fix tests Signed-off-by: Lukas Kral <lukywill16@gmail.com> update documentation, fix more tests, and apply comments from Paul Signed-off-by: Lukas Kral <lukywill16@gmail.com> comments Signed-off-by: Lukas Kral <lukywill16@gmail.com> excluded principals Signed-off-by: Lukas Kral <lukywill16@gmail.com> bump quotas plugin to 0.3.1 and do changes to code Signed-off-by: Lukas Kral <lukywill16@gmail.com> fix UT and update ST for the quotas plugin Signed-off-by: Lukas Kral <lukywill16@gmail.com> Jakub's and Paolo's comments Signed-off-by: Lukas Kral <lukywill16@gmail.com>
8e26e4d
to
dfc35e6
Compare
Signed-off-by: Lukas Kral <lukywill16@gmail.com>
Signed-off-by: Lukas Kral <lukywill16@gmail.com>
@scholzj @ppatierno I resolved the comments -> some of them I kept open just because I'm not sure if the wording or my solution is 100% correct. Once you have time, could you please have another look? |
Type of change
Description
This PR adds Quotas API to Kafka CR based on Quotas management proposal and updates Strimzi Quotas Plugin version to 0.3.1 (and also it reflects changes based on Cluster Wide Volume Usage Quota Management).
It also changes the
QuotasST
, which need to reflect changes done in Strimzi Quotas Plugin 0.3.1.Closes #9097, #9859
Checklist
Please go through this checklist and make sure all applicable tasks have been done