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

Support Multiple controllers #167

Merged
merged 26 commits into from
Aug 28, 2023

Conversation

SamBarker
Copy link
Member

Type of change

  • Bugfix
  • Enhancement

Description

Fixes the cluster configuration and start up so that multiple controller nodes work. Fixes: #165

Additional Context

I still see this as an intermediate step, there are kludges to detect if a node should be a controller or a broker or both. While they work it feels like we are missing a proper object model that knows what role a node has. We also lack the ability for users to control the cluster topology (i.e. they can't have nodes in controller only mode with while they they still have brokers to start)

Checklist

Please go through this checklist and make sure all applicable tasks have been done

  • Write tests
  • Make sure all tests pass
  • Update documentation
  • Reference relevant issue(s) and close them after merging
  • Update CHANGELOG.md


private void assertNodeIdHasRole(KafkaClusterConfig kafkaClusterConfig, int nodeId, String expectedRole) {
final var config = kafkaClusterConfig.generateConfigForSpecificNode(endpointConfig, nodeId);
assertThat(config.getProperties()).extracting(brokerConfig -> brokerConfig.get("process.roles")).as("nodeId: %s to have process.roles", nodeId).isEqualTo(
Copy link
Contributor

Choose a reason for hiding this comment

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

We should switch to using the kafka enums throughout in another PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ohh that is a good thought

@@ -93,6 +98,11 @@ public static KafkaCluster create(KafkaClusterConfig clusterConfig) {
}
}

private static KafkaClusterExecutionMode getExecutionMode(KafkaClusterConfig clusterConfig) {
return KafkaClusterExecutionMode.convertClusterExecutionMode(System.getenv().get(TEST_CLUSTER_EXECUTION_MODE),
Copy link
Contributor

Choose a reason for hiding this comment

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

not part of your changes but it looks a bit dangerous that it defaults it if the string is unknown, maybe better to explode with error if the user supplies value "CONTAINDERER"

Copy link
Contributor

@robobario robobario left a comment

Choose a reason for hiding this comment

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

LGTM, good to have all the language aligned on node/broker/controller thanks @SamBarker

Would be good to have another round on KafkaClusterConfig to try and move away from going from the configuration straight to server properties, passing those maps down to collect protocols/listeners/etc. Maybe there's some intermediate representation missing like: TestDefinition -> Nodes -> Properties where Nodes describes how we want the cluster to look.

@tombentley
Copy link
Contributor

We should probably update the README and the javadocs on the @KRaftCluster annotation to explain how the numBrokers and numControllers relate to the cluster that gets created.

I also think that with this change you're not far from being able to add support for controlling whether we use combined or pure-controller nodes using some combinedMode attribute on @KRaftCluster. Maybe that's something we can do in a follow-up PR, WDYT?

@SamBarker
Copy link
Member Author

We should probably update the README and the javadocs on the @KRaftCluster annotation to explain how the numBrokers and numControllers relate to the cluster that gets created.

Yeah thats a good point.

I also think that with this change you're not far from being able to add support for controlling whether we use combined or pure-controller nodes using some combinedMode attribute on @KRaftCluster. Maybe that's something we can do in a follow-up PR, WDYT?

Yeah I've questioned the use of combined mode throughout this work but I really don't want to try and tackle it as part of this PR. Partly because I wonder if at that point we want to move to a more sophisticated deployment model such as @KraftCluster(brokerIds = [1,2,4], controllerId=1,2,6]) but keep numBrokers/ numControllers as a fall back...

Signed-off-by: Sam Barker <[email protected]>
When the build fails archiving the container logs also failed as the previous format contained `:`.

Signed-off-by: Sam Barker <[email protected]>
Signed-off-by: Sam Barker <[email protected]>
Signed-off-by: Sam Barker <[email protected]>
Extracting methods in the process.

Signed-off-by: Sam Barker <[email protected]>
Signed-off-by: Sam Barker <[email protected]>
README.md Outdated
@@ -74,6 +74,17 @@ When multiple constraints are provided they will _all_ be satisfied.

The cluster will be provisioned using the fastest available mechanism, because your development inner loop is a precious thing.

## Provisioning topology

In kraft cluster (the default) the extension will generate nodes using the `broker, controller` roles until it reaches the desired number of brokers or controllers (which ever is lowest) at which point it will continue deploying the remaining role.
Copy link
Contributor

Choose a reason for hiding this comment

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

In kraft cluster

Should we introduce some term like cluster mode [kraft, zookeeper]?

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, my first draft locally I called it kraft mode but thought a kraft cluster aligned better with the use of the KraftCluster annotation.

The mode terminology would be extension specific as Apache Kafka talks about KRaft clusters IIRC

Signed-off-by: Sam Barker <[email protected]>
Signed-off-by: Sam Barker <[email protected]>
README.md Outdated Show resolved Hide resolved
Co-authored-by: Robert Young <[email protected]>
Signed-off-by: Sam Barker <[email protected]>
@sonarcloud
Copy link

sonarcloud bot commented Aug 28, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 4 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

Copy link
Contributor

@robobario robobario left a comment

Choose a reason for hiding this comment

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

LGTM

@SamBarker SamBarker merged commit 1418b32 into kroxylicious:main Aug 28, 2023
3 checks passed
@SamBarker SamBarker deleted the multipleControllers branch August 28, 2023 01:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to stand up a 3 controller KRaft-based cluster
3 participants