-
Notifications
You must be signed in to change notification settings - Fork 1k
Do not enable TopicAccessValidator if Kafka has unsupported authorizedOperations #2888
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
Changes from 2 commits
c9a44e6
2195332
318e70e
2a60a5b
1ef65b1
5ab8735
1ac3033
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,8 +21,11 @@ | |
| import java.util.Collection; | ||
| import java.util.Collections; | ||
| import java.util.Map; | ||
|
|
||
| import org.apache.kafka.clients.admin.AdminClient; | ||
| import org.apache.kafka.clients.admin.Config; | ||
| import org.apache.kafka.clients.admin.DescribeClusterOptions; | ||
| import org.apache.kafka.clients.admin.DescribeClusterResult; | ||
| import org.apache.kafka.common.Node; | ||
| import org.apache.kafka.common.config.ConfigResource; | ||
| import org.slf4j.Logger; | ||
|
|
@@ -35,6 +38,18 @@ private KafkaClusterUtil() { | |
|
|
||
| } | ||
|
|
||
| public static boolean isAuthorizedOperationsSupported(final AdminClient adminClient) { | ||
| try { | ||
| final DescribeClusterResult authorizedOperations = adminClient.describeCluster( | ||
| new DescribeClusterOptions().includeAuthorizedOperations(true) | ||
| ); | ||
|
|
||
| return authorizedOperations.authorizedOperations().get() != null; | ||
| } catch (Exception e) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we need to check for
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think so. By the time this method is called, the |
||
| throw new KsqlServerException("Could not get Kafka authorized operations!", e); | ||
| } | ||
| } | ||
|
|
||
| public static Config getConfig(final AdminClient adminClient) { | ||
| try { | ||
| final Collection<Node> brokers = adminClient.describeCluster().nodes().get(); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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 we should log this at warning level. The resulting behavior is likely not what the user intended. Might be good to get Michael Drogalis (@MichaelDrogalis) take on what the behavior should be - maybe it would be better to just hard-fail and require the user to either upgrade Kafka or not configure the validator.
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.
The topic access validator is used mostly to provide better permission error messages when the KSQL user won't be able to execute a persistent query on KSQL. I don't think a warning message is a correct level for that case (I am not against about it, though). However, failing KSQL because is not using the correct version of Kafka might be out of scope of our current release. Do we have a compatibility list of Kafka versions that KSQL should support?
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 agree with Sergio Peña (@spena) that it's probably a bit late to introduce a code-path to hard-fail here -- though switching the log level up to
warndoes feel like the right play to me. Sergio Peña (@spena) Can you expand a bit about why you thinkinfois right here? Maybe I'm missing some nuance.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 feel it's not a
warnbecause if permission checks are not available, KSQL will still fail further in the code without providing good error messages. However, it is harmless to switch the level towarnnow that I am thinking about it. I will do the switch and update this PR.