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

KAFKA-18399 Remove ZooKeeper from KafkaApis (6/N): CREATE_ACLS, DELETE_ACLS #18454

Open
wants to merge 5 commits into
base: trunk
Choose a base branch
from

Conversation

tedyyan
Copy link
Contributor

@tedyyan tedyyan commented Jan 9, 2025

*More detailed description of your change,
Delete follow KafkaApi handler

handleCreateAcls
handleDeleteAcls
In Kraft mode, all requests are forwarded to controller and all authorization is not work so I delete some tests.

Forwarding test already cover by

testRaftShouldAlwaysForwardCreateAcls
testRaftShouldAlwaysForwardDeleteAcls

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 triage PRs from the community core Kafka Broker small Small PRs labels Jan 9, 2025
@tedyyan tedyyan changed the title KAFKA-18399 Remove ZooKeeper from KafkaApis (teddy) KAFKA-18399 Remove ZooKeeper from KafkaApis (6/N): CREATE_ACLS, DELETE_ACLS Jan 9, 2025
Comment on lines +226 to +227
case ApiKeys.CREATE_ACLS => maybeForwardToController(request, forwardToControllerOrFail)
case ApiKeys.DELETE_ACLS => maybeForwardToController(request, forwardToControllerOrFail)
Copy link
Contributor

Choose a reason for hiding this comment

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

Please revert these change.

Comment on lines -2622 to -2631
def handleCreateAcls(request: RequestChannel.Request): Unit = {
metadataSupport.requireZkOrThrow(KafkaApis.shouldAlwaysForward(request))
aclApis.handleCreateAcls(request)
}

def handleDeleteAcls(request: RequestChannel.Request): Unit = {
metadataSupport.requireZkOrThrow(KafkaApis.shouldAlwaysForward(request))
aclApis.handleDeleteAcls(request)
}

Copy link
Contributor

Choose a reason for hiding this comment

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

We can just throw exception within the two method.

Comment on lines 1199 to 1210
@Test
def testCreateAclWithForwarding(): Unit = {
val requestBuilder = new CreateAclsRequest.Builder(new CreateAclsRequestData())
testForwardableApi(ApiKeys.CREATE_ACLS, requestBuilder)
}

@Test
def testDeleteAclWithForwarding(): Unit = {
val requestBuilder = new DeleteAclsRequest.Builder(new DeleteAclsRequestData())
testForwardableApi(ApiKeys.DELETE_ACLS, requestBuilder)
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Please revert this change. These tests should be retained.

Comment on lines 10862 to 10874
@Test
def testRaftShouldAlwaysForwardCreateAcls(): Unit = {
metadataCache = MetadataCache.kRaftMetadataCache(brokerId, () => KRaftVersion.KRAFT_VERSION_0)
kafkaApis = createKafkaApis(raftSupport = true)
verifyShouldAlwaysForwardErrorMessage(kafkaApis.handleCreateAcls)
}

@Test
def testRaftShouldAlwaysForwardDeleteAcls(): Unit = {
metadataCache = MetadataCache.kRaftMetadataCache(brokerId, () => KRaftVersion.KRAFT_VERSION_0)
kafkaApis = createKafkaApis(raftSupport = true)
verifyShouldAlwaysForwardErrorMessage(kafkaApis.handleDeleteAcls)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

@xuayan-nokia
Copy link

looks like very simple fix, but If just throw exception, I don't know whether it can pass the unit test.

@TaiJuWu
Copy link
Contributor

TaiJuWu commented Jan 9, 2025

looks like very simple fix, but If just throw exception, I don't know whether it can pass the unit test.

In zk mode, we do these operations on local but in Kraft mode we just forward requests to controller.
We don't convert all kafkaApisTest to Kraft mode from zk mode, if possible could you help to check tests related these apis?

@@ -2620,13 +2620,11 @@ class KafkaApis(val requestChannel: RequestChannel,
}

def handleCreateAcls(request: RequestChannel.Request): Unit = {
metadataSupport.requireZkOrThrow(KafkaApis.shouldAlwaysForward(request))
aclApis.handleCreateAcls(request)
throw KafkaApis.shouldNeverReceive(request)
Copy link
Contributor

@mingdaoy mingdaoy Jan 9, 2025

Choose a reason for hiding this comment

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

Should it be throw KafkaApis.shouldAlwaysForward(request) instead? cc. @TaiJuWu

Choose a reason for hiding this comment

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

you're right, I reverted it because this comment: #18454 (comment)

Copy link
Contributor

@TaiJuWu TaiJuWu Jan 10, 2025

Choose a reason for hiding this comment

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

You can throw exception here and keep #18454 (comment)
Here is an example https://github.com/apache/kafka/pull/18447/files

Sorry, throw throw KafkaApis.shouldAlwaysForward(request) like @mingdaoy said.

}

def handleDeleteAcls(request: RequestChannel.Request): Unit = {
metadataSupport.requireZkOrThrow(KafkaApis.shouldAlwaysForward(request))
aclApis.handleDeleteAcls(request)
throw KafkaApis.shouldNeverReceive(request)
Copy link
Contributor

@mingdaoy mingdaoy Jan 9, 2025

Choose a reason for hiding this comment

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

Should it be throw KafkaApis.shouldAlwaysForward(request) instead?

Choose a reason for hiding this comment

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

you're right, I reverted it because this comment: #18454 (comment)

Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

@github-actions github-actions bot removed the triage PRs from the community label Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci-approved core Kafka Broker small Small PRs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants