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-18028: the effective kraft version of --no-initial-controllers should be 1 rather than 0 #17836

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from

Conversation

FrankYang0529
Copy link
Member

@FrankYang0529 FrankYang0529 commented Nov 17, 2024

The hasDynamicQuorum only considers the initialControllers, which is configured when either --initial-controllers or --standalone is specified. It will result in the following unexpected behaviors:

  1. Using the no-initial-controllers configuration get kraft.version=0
  2. This leads to a command error when executing --no-initial-controllers --feature kraft.version=1
> ./bin/kafka-storage.sh format -t "zuV6tFqAQhSGfFe97O-9cw" --config ./config/kraft/controller3.properties --no-initial-controllers --feature kraft.version=1
Cannot set kraft.version to 1 unless KIP-853 configuration is present. Try removing the --feature flag for kraft.version.

To fix this, we should also allow --no-initial-controllers with --feature kraft.version=1.

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 core Kafka Broker kraft labels Nov 17, 2024
Copy link
Contributor

@ahuang98 ahuang98 left a comment

Choose a reason for hiding this comment

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

thanks for addressing this issue!

@@ -143,6 +143,9 @@ object StorageTool extends Logging {
if (namespace.getBoolean("standalone")) {
formatter.setInitialControllers(createStandaloneDynamicVoters(config))
}
if (namespace.getBoolean("no_initial_controllers")) {
formatter.setNoInitialControllers(true)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: can we change the if statement below into an else clause?

@@ -130,6 +132,7 @@ public class Formatter {
* The initial KIP-853 voters.
*/
private Optional<DynamicVoters> initialControllers = Optional.empty();
private boolean noInitialControllers = false;
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: thoughts on calling this noInitialControllersFlag? might make it more clear this is not just set when initial-controllers is not supplied

@FrankYang0529
Copy link
Member Author

Hi @ahuang98, thanks for the review. I address all comments.

@ahuang98
Copy link
Contributor

@FrankYang0529 thank you! Last two requests, I was wondering if you could add the sequence of events/commands for reproducing the issue to the PR description, and also test your change manually (bring up kraft quorum locally)?

@FrankYang0529
Copy link
Member Author

Hi @ahuang98, thanks for the review. I will update description and test manually tomorrow.

@FrankYang0529
Copy link
Member Author

Hi @ahuang98, I updated PR description and following is manually test results:

  1. Setup three controller properties.
# path: ./config/kraft/controller1.properties
process.roles=controller
node.id=1
controller.quorum.bootstrap.servers=localhost:9093
listeners=CONTROLLER://:9093
advertised.listeners=CONTROLLER://localhost:9093
controller.listener.names=CONTROLLER
log.dirs=/tmp/kraft-controller-logs-1
# path: ./config/kraft/controller2.properties
process.roles=controller
node.id=2
controller.quorum.bootstrap.servers=localhost:9093
listeners=CONTROLLER://:9094
advertised.listeners=CONTROLLER://localhost:9094
controller.listener.names=CONTROLLER
log.dirs=/tmp/kraft-controller-logs-2
# path: ./config/kraft/controller3.properties
process.roles=controller
node.id=3
controller.quorum.bootstrap.servers=localhost:9093
listeners=CONTROLLER://:9095
advertised.listeners=CONTROLLER://localhost:9095
controller.listener.names=CONTROLLER
log.dirs=/tmp/kraft-controller-logs-3
  1. Format node 1 as first standalone controller and start it.
> ./bin/kafka-storage.sh format -t "zuV6tFqAQhSGfFe97O-9cw" --config ./config/kraft/controller1.properties --standalone
Formatting dynamic metadata voter directory /tmp/kraft-controller-logs-1 with metadata.version 4.0-IV0.
> ./bin/kafka-server-start.sh ./config/kraft/controller1.properties
  1. Format node 2 with no initial controller and start it.
> ./bin/kafka-storage.sh format -t "zuV6tFqAQhSGfFe97O-9cw" --config ./config/kraft/controller2.properties --no-initial-controllers --feature kraft.version=1
Formatting metadata directory /tmp/kraft-controller-logs-2 with metadata.version 4.0-IV0.
> ./bin/kafka-server-start.sh ./config/kraft/controller2.properties
  1. Format node 3 with no initial controller and start it.
> ./bin/kafka-storage.sh format -t "zuV6tFqAQhSGfFe97O-9cw" --config ./config/kraft/controller3.properties --no-initial-controllers --feature kraft.version=1
Formatting metadata directory /tmp/kraft-controller-logs-3 with metadata.version 4.0-IV0.
> ./bin/kafka-server-start.sh ./config/kraft/controller3.properties
  1. Check cluster status is 1 controller with 2 observers.
> ./bin/kafka-metadata-quorum.sh --bootstrap-controller localhost:9093 describe --status
ClusterId:              zuV6tFqAQhSGfFe97O-9cw
LeaderId:               1
LeaderEpoch:            1
HighWatermark:          817
MaxFollowerLag:         0
MaxFollowerLagTimeMs:   0
CurrentVoters:          [{"id": 1, "directoryId": "zD1nHI9OSyCGu29l3db2yg", "endpoints": ["CONTROLLER://localhost:9093"]}]
CurrentObservers:       [{"id": 2, "directoryId": "vX3tLI_VJKRLAMqJdFUY4Q"}, {"id": 3, "directoryId": "Mk1bbuDgirHiGzOnH4okew"}]
  1. Add node 2 as controller and check cluster status is 2 controllers and 1 observer.
> ./bin/kafka-metadata-quorum.sh --bootstrap-controller localhost:9093 --command-config ./config/kraft/controller2.properties add-controller
Added controller 2 with directory id vX3tLI_VJKRLAMqJdFUY4Q and endpoints: CONTROLLER://localhost:9094
> ./bin/kafka-metadata-quorum.sh --bootstrap-controller localhost:9093 describe --status
ClusterId:              zuV6tFqAQhSGfFe97O-9cw
LeaderId:               1
LeaderEpoch:            1
HighWatermark:          960
MaxFollowerLag:         0
MaxFollowerLagTimeMs:   0
CurrentVoters:          [{"id": 1, "directoryId": "zD1nHI9OSyCGu29l3db2yg", "endpoints": ["CONTROLLER://localhost:9093"]}, {"id": 2, "directoryId": "vX3tLI_VJKRLAMqJdFUY4Q", "endpoints": ["CONTROLLER://localhost:9094"]}]
CurrentObservers:       [{"id": 3, "directoryId": "Mk1bbuDgirHiGzOnH4okew"}]
  1. Add node 3 as controller and check cluster status is 3 controllers and 0 observer.
> ./bin/kafka-metadata-quorum.sh --bootstrap-controller localhost:9093 --command-config ./config/kraft/controller3.properties add-controller
Added controller 3 with directory id Mk1bbuDgirHiGzOnH4okew and endpoints: CONTROLLER://localhost:9095
> ./bin/kafka-metadata-quorum.sh --bootstrap-controller localhost:9093 describe --status
ClusterId:              zuV6tFqAQhSGfFe97O-9cw
LeaderId:               1
LeaderEpoch:            1
HighWatermark:          1123
MaxFollowerLag:         0
MaxFollowerLagTimeMs:   0
CurrentVoters:          [{"id": 1, "directoryId": "zD1nHI9OSyCGu29l3db2yg", "endpoints": ["CONTROLLER://localhost:9093"]}, {"id": 2, "directoryId": "vX3tLI_VJKRLAMqJdFUY4Q", "endpoints": ["CONTROLLER://localhost:9094"]}, {"id": 3, "directoryId": "Mk1bbuDgirHiGzOnH4okew", "endpoints": ["CONTROLLER://localhost:9095"]}]
CurrentObservers:       []

@FrankYang0529
Copy link
Member Author

FrankYang0529 commented Nov 21, 2024

BTW, I found the adding controller command is different from the KIP-853. Create a followup Jira: https://issues.apache.org/jira/browse/KAFKA-18059.

@chia7712
Copy link
Contributor

I found the adding controller command is different from the KIP-853. Create a followup Jira:

nice find and I have added feedback on the jira

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Kafka Broker kraft
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants