Skip to content

KAFKA-18440: Admin does not convert the AuthorizationException to fatal error in using bootstrap controllers#18435

Merged
divijvaidya merged 1 commit intoapache:trunkfrom
FrankYang0529:KAFKA-18440
Jan 10, 2025
Merged

KAFKA-18440: Admin does not convert the AuthorizationException to fatal error in using bootstrap controllers#18435
divijvaidya merged 1 commit intoapache:trunkfrom
FrankYang0529:KAFKA-18440

Conversation

@FrankYang0529
Copy link
Copy Markdown
Member

Admin use DescribeClusterRequest to build metadata when using bootstrap controllers, and controller APIs may return ClusterAuthorizationException when users have no "ALTER" permission (see #14306 (comment)).

However, admin does not convert the authorized exception to fatal exception (https://github.com/apache/kafka/blob/trunk/clients/src/main/java/org/apache/kafka/clients/admin/internals/AdminMetadataManager.java#L276), so it keeps sending the request to controller until timeout.

  • unit test: AdminMetadataManagerTest#testAuthorizationFailure
  • integration test: ClusterTestExtensionsTest#testSaslPlaintext

Committer Checklist (excluded from commit message)

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

@github-actions github-actions Bot added clients small Small PRs labels Jan 8, 2025
@@ -280,6 +281,9 @@ public void updateFailed(Throwable exception) {
if (exception instanceof AuthenticationException) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please add a function isFatalException and add AuthenticationException, AuthorizationException, SecurityDisabledException, UnsupportedEndpointTypeException, UnsupportedForMessageFormatException, UnsupportedVersionException etc.

You can add this function in RequestUtils class.

Copy link
Copy Markdown
Member Author

@FrankYang0529 FrankYang0529 Jan 8, 2025

Choose a reason for hiding this comment

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

Thanks for the review. This Jira would like to focus on fatal exception for metadata call in Admin.

IIRC, The SecurityDisabledException is used in create / delete ACLs and UnsupportedForMessageFormatException is used in produce request, so I don't add them.

Also, in UnsupportedVersionException, it logs different message for bootstrap and controller node, but other exceptions logs same message for different node type, so I don't encapsulate all exceptions in a utility function.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I understand that this is increasing the scope of the JIRA. What I am trying to suggest here will help us prevent such problems in future for cases where a client retries on a fatal exception. If we have a utility method, we can consolidate the logic of what is considered fatal at one place and existing/future calls to server APIs can use that utility to handle exceptions. It will prevent bugs in future if new authors can use the utility method.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks for the comment. Yeah, it's good to have a utility function for it. I add it to RequestUtils#isFatalException.

@FrankYang0529 FrankYang0529 force-pushed the KAFKA-18440 branch 2 times, most recently from 6ba95ba to e9d5260 Compare January 9, 2025 16:02
@github-actions github-actions Bot removed the small Small PRs label Jan 9, 2025
…al error in using bootstrap controllers

Signed-off-by: PoAn Yang <payang@apache.org>
@divijvaidya divijvaidya merged commit 2b7c039 into apache:trunk Jan 10, 2025
@divijvaidya divijvaidya added the backport-candidate This pull request is a candidate to be backported to previous versions label Jan 10, 2025
@FrankYang0529 FrankYang0529 deleted the KAFKA-18440 branch January 10, 2025 10:21
m1a2st pushed a commit to m1a2st/kafka that referenced this pull request Jan 10, 2025
ijuma added a commit to ijuma/kafka that referenced this pull request Jan 10, 2025
…emove-metadata-version-methods-for-versions-older-than-3.0

* apache-github/trunk:
  KAFKA-18340: Change Dockerfile to use log4j2 yaml instead log4j properties (apache#18378)
  MINOR: fix flaky RemoteLogManagerTest#testStopPartitionsWithDeletion (apache#18474)
  KAFKA-18311: Enforcing copartitioned topics (4/N) (apache#18397)
  KAFKA-18308; Update CoordinatorSerde (apache#18455)
  KAFKA-18440: Convert AuthorizationException to fatal error in AdminClient (apache#18435)
  KAFKA-17671: Create better documentation for transactions (apache#17454)
  KAFKA-18304; Introduce json converter generator (apache#18458)
  MINOR: Clean up classic group tests (apache#18473)
  KAFKA-18399 Remove ZooKeeper from KafkaApis (2/N): CONTROLLED_SHUTDOWN and ENVELOPE (apache#18422)
  MINOR: improve StreamThread periodic processing log (apache#18430)
FrankYang0529 added a commit to FrankYang0529/kafka that referenced this pull request Jan 13, 2025
…ient (apache#18435)

Reviewers: Divij Vaidya <diviv@amazon.com>
(cherry picked from commit 2b7c039)
FrankYang0529 added a commit to FrankYang0529/kafka that referenced this pull request Jan 13, 2025
…ient (apache#18435)

Reviewers: Divij Vaidya <diviv@amazon.com>
(cherry picked from commit 2b7c039)
@FrankYang0529
Copy link
Copy Markdown
Member Author

Hi @divijvaidya, I create another two PRs for 3.9 and 3.8 branches, because there is conflict. 4.0 backport doesn't have conflict, so I don't create one for it. Thanks.

3.9: #18502
3.9: #18503

pranavt84 pushed a commit to pranavt84/kafka that referenced this pull request Jan 27, 2025
manoj-mathivanan pushed a commit to manoj-mathivanan/kafka that referenced this pull request Feb 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-candidate This pull request is a candidate to be backported to previous versions ci-approved clients

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants