Skip to content

KAFKA-18399 Remove ZooKeeper from KafkaApis (3/N): ALTER_CONFIG, INCREMENETAL_ALTER_CONFIG#18432

Merged
chia7712 merged 13 commits intoapache:trunkfrom
TaiJuWu:rm_zk-2
Jan 15, 2025
Merged

KAFKA-18399 Remove ZooKeeper from KafkaApis (3/N): ALTER_CONFIG, INCREMENETAL_ALTER_CONFIG#18432
chia7712 merged 13 commits intoapache:trunkfrom
TaiJuWu:rm_zk-2

Conversation

@TaiJuWu
Copy link
Copy Markdown
Collaborator

@TaiJuWu TaiJuWu commented Jan 8, 2025

*More detailed description of your change,

  • Remove ALTER_CONFIG zk part
  • Remove INCREMENETAL_ALTER_CONFIG zk part

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 labels Jan 8, 2025
Comment thread core/src/main/scala/kafka/server/KafkaApis.scala
Comment thread core/src/main/scala/kafka/server/KafkaApis.scala
Comment thread core/src/test/scala/unit/kafka/server/KafkaApisTest.scala Outdated
}

@Test
def testAlterConfigsWithAuthorizer(): Unit = {
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

ZK only test.

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.

For my understanding, this is a ZK-only test because authorisation should no longer happen on a broker because the requests are forwarded to the KRaft controller where authorisation ought to happen?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

yes, we don't don any authorization on Kraft mode.

Copy link
Copy Markdown
Member

@ijuma ijuma Jan 10, 2025

Choose a reason for hiding this comment

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

You still need to do some level of authorization before forwarding, right?

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.

You still need to do some level of authorization before forwarding

You are absolutely correct. The log4j operation is not forwarded to the controller because it is used to configure "this" specific broker. Therefore, authorization for this operation must be performed within this broker.

Please ensure that the related unit tests are maintained.

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.

Thanks for the quick response! I understand where you are coming from with respect to the particular operation we are authorizing, what I do not understand is why are we removing the double authorisation (once on the broker and once on the controller)? I also believe this is what Ismael meant as well here #18432 (comment)

Copy link
Copy Markdown
Collaborator Author

@TaiJuWu TaiJuWu Jan 13, 2025

Choose a reason for hiding this comment

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

Oh, I got your point but this should be another issue and we can make it as follow ups.
We should not block it here since this ticket is for 4.0 and we are closer deadline and it more like an optimization.

This is a mistake see #18432 (comment)

Copy link
Copy Markdown
Collaborator Author

@TaiJuWu TaiJuWu Jan 13, 2025

Choose a reason for hiding this comment

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

By the way, here is a related response #18432 (comment) for #18432 (comment) and I believe it is an accident.

The question should be we should authorize for IncrementalAlterConfig instead of AlterConfig

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.

but this should be another issue and we can make it as follow ups.

Pardon me, what is "another issue"? There is no extra authorisation for AlterConfigsRequest as it does not support to change logger. It seems to me the follow-up for this unit test is to add checks for configManager.preprocess

Copy link
Copy Markdown
Collaborator Author

@TaiJuWu TaiJuWu Jan 13, 2025

Choose a reason for hiding this comment

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

but this should be another issue and we can make it as follow ups.

Pardon me, what is "another issue"? There is no extra authorisation for AlterConfigsRequest as it does not support to change logger. It seems to me the follow-up for this unit test is to add checks for configManager.preprocess

Oh, sorry. I think this again.
All alterConfig (no matter incremental or not ) should forward to controller directly so there is no follow up.
Previous image (from mine), we can do some authorize locally but no matter what we always need to send to controller.
There is no optimism space.

Comment thread core/src/test/scala/unit/kafka/server/KafkaApisTest.scala
Comment thread core/src/test/scala/unit/kafka/server/KafkaApisTest.scala Outdated
Comment thread core/src/test/scala/unit/kafka/server/KafkaApisTest.scala Outdated
@TaiJuWu TaiJuWu marked this pull request as ready for review January 8, 2025 05:58
@TaiJuWu TaiJuWu marked this pull request as draft January 8, 2025 12:25
@TaiJuWu TaiJuWu changed the title KAFKA-18399 Remove ZooKeeper from KafkaApis (part 3):INIT_PRODUCER_ID, ALTER_CONFIG, INCREMENETAL_ALTER_CONFIG KAFKA-18399 Remove ZooKeeper from KafkaApis (part 3): ALTER_CONFIG, INCREMENETAL_ALTER_CONFIG Jan 8, 2025
@TaiJuWu TaiJuWu marked this pull request as ready for review January 8, 2025 18:32
Comment thread core/src/test/scala/unit/kafka/server/KafkaApisTest.scala
@github-actions github-actions Bot removed the triage PRs from the community label Jan 9, 2025
@TaiJuWu TaiJuWu changed the title KAFKA-18399 Remove ZooKeeper from KafkaApis (part 3): ALTER_CONFIG, INCREMENETAL_ALTER_CONFIG KAFKA-18399 Remove ZooKeeper from KafkaApis (3/N): ALTER_CONFIG, INCREMENETAL_ALTER_CONFIG Jan 9, 2025
response => sendResponse(response.map(_.data())))
} else {
sendResponse(Some(processLegacyAlterConfigsRequest(request, remaining)))
throw KafkaApis.shouldAlwaysForward(request)
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.

How could this happen in kraft mode? Do we need to change some code to make it impossible or is it already impossible? I'd rather do this in a generic way versus having each handler having to handle it.

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.

metadataSupport.canForward() is always true in kraft and request does not have envelope in kraft broker. Hence, it would be better to simplify the code by removing the unnecessary path. for example:

    if (remaining.resources().isEmpty) {
      sendResponse(Some(new AlterConfigsResponseData()))
    } else {
      metadataSupport.forwardingManager.get.forwardRequest(request,
        new AlterConfigsRequest(remaining, request.header.apiVersion()),
        response => sendResponse(response.map(_.data())))
    }

BTW, I file https://issues.apache.org/jira/browse/KAFKA-18472 to cleanup metadataSupport

Copy link
Copy Markdown
Contributor

@clolov clolov left a comment

Choose a reason for hiding this comment

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

Did a first pass and left a couple of small questions for my understanding

}

@Test
def testAlterConfigsWithAuthorizer(): Unit = {
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.

For my understanding, this is a ZK-only test because authorisation should no longer happen on a broker because the requests are forwarded to the KRaft controller where authorisation ought to happen?

def handleIncrementalAlterConfigsRequest(request: RequestChannel.Request): Unit = {
val original = request.body[IncrementalAlterConfigsRequest]
val preprocessingResponses = configManager.preprocess(original.data(),
(rType, rName) => authHelper.authorize(request.context, ALTER_CONFIGS, rType, rName))
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.

For my understanding (and here I am working under the assumption that these requests ought to be authorised on the KRaft controller now), should this be removed as well?

Copy link
Copy Markdown
Collaborator Author

@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.

when we set broker config (only for LOG4J), we also need to do authorization locally so we need to keep this one.

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.

Got it, thank you!

Copy link
Copy Markdown
Member

@chia7712 chia7712 left a comment

Choose a reason for hiding this comment

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

@TaiJuWu thanks for this patch

Comment thread core/src/main/scala/kafka/server/KafkaApis.scala Outdated
}

@Test
def testAlterConfigsWithAuthorizer(): Unit = {
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.

You still need to do some level of authorization before forwarding

You are absolutely correct. The log4j operation is not forwarded to the controller because it is used to configure "this" specific broker. Therefore, authorization for this operation must be performed within this broker.

Please ensure that the related unit tests are maintained.

val forwardCallback: ArgumentCaptor[Option[AbstractResponse] => Unit] = ArgumentCaptor.forClass(classOf[Option[AbstractResponse] => Unit])
val newBody: ArgumentCaptor[AbstractRequest] = ArgumentCaptor.forClass(classOf[AbstractRequest])

verify(forwardingManager).forwardRequest(
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.

all we want to verify is the method forwardRequest gets executed only once, right? the following assert is unnecessary as they never be null.

Copy link
Copy Markdown
Member

@chia7712 chia7712 left a comment

Choose a reason for hiding this comment

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

@TaiJuWu thanks for this patch. one small comment is left.

val requestHeader = new RequestHeader(ApiKeys.ALTER_CONFIGS, ApiKeys.ALTER_CONFIGS.latestVersion, clientId, 0)
val request = buildRequest(
new AlterConfigsRequest.Builder(configs.asJava, false).build(requestHeader.apiVersion))
val apiRequest = new AlterConfigsRequest.Builder(configs.asJava, false).build(requestHeader.apiVersion)
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.

in this testAlterConfigsClientMetrics, we don't need the authorizer. Hence, could you please remove the unused variable?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done. Thanks for review!

@chia7712
Copy link
Copy Markdown
Member

the failed tests are in clients module, so I think they are unrelated to this PR

@chia7712 chia7712 merged commit 3fcaec7 into apache:trunk Jan 15, 2025
chia7712 pushed a commit that referenced this pull request Jan 15, 2025
…INCREMENETAL_ALTER_CONFIG (#18432)

Reviewers: Christo Lolov <lolovc@amazon.com>, Ismael Juma <ismael@juma.me.uk>, Chia-Ping Tsai <chia7712@gmail.com>
@TaiJuWu TaiJuWu deleted the rm_zk-2 branch January 15, 2025 11:40
pranavt84 pushed a commit to pranavt84/kafka that referenced this pull request Jan 27, 2025
…INCREMENETAL_ALTER_CONFIG (apache#18432)

Reviewers: Christo Lolov <lolovc@amazon.com>, Ismael Juma <ismael@juma.me.uk>, Chia-Ping Tsai <chia7712@gmail.com>
airlock-confluentinc Bot pushed a commit to confluentinc/kafka that referenced this pull request Jan 27, 2025
…INCREMENETAL_ALTER_CONFIG (apache#18432)

Reviewers: Christo Lolov <lolovc@amazon.com>, Ismael Juma <ismael@juma.me.uk>, Chia-Ping Tsai <chia7712@gmail.com>
manoj-mathivanan pushed a commit to manoj-mathivanan/kafka that referenced this pull request Feb 19, 2025
…INCREMENETAL_ALTER_CONFIG (apache#18432)

Reviewers: Christo Lolov <lolovc@amazon.com>, Ismael Juma <ismael@juma.me.uk>, Chia-Ping Tsai <chia7712@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants