Status
Current state: Under Discussion
Discussion thread:
JIRA: KMETA-1086
Motivation
Some users run KRaft controllers and brokers on the same machine (not containerized, but through tarballs, etc). Prior to KRaft, when running ZooKeeper and Kafka on the same machine, users could independently stop the ZooKeeper node and Kafka broker since there were specific shell scripts for each (zookeeper-server-stop and kafka-server-stop, respectively).
However in KRaft mode, they can't stop the KRaft controller independently from the Kafka broker because there is just a single script that doesn't distinguish between the two processes and signals both of them. We need to provide a way for users to kill either controllers or brokers.
Public Interfaces
The command line for stopping Kafka nodes will include a new optional parameter to support identifying a specific process to stop based on the contents of the node's configuration file (specifically, the process.roles value).
Instead of simply running
./bin/kafka-server-stop.sh
The new script will accept an optional parameter "--process.roles <value>" to indicate that the script should only kill Kafka processes that are running with that value for the config. For example, the new command to kill broker only will look like:
./bin/kafka-server-stop.sh --process.roles broker
When a "process.roles" field is not provided, the behavior remains unchanged -- all Kafka processes are stopped.
Proposed Changes
I'm changing the "kafka-server-stop.sh" file to accept an optional field, process role. When the user specify a process role, I will retrieve the absolute path to the configuration file, and search for the value of "process.roles". If the "process.roles" from the configuration file matches the process role the user provided, that process will be killed, otherwise it will be skipped.
NOTE: If users want to use the feature, they have to provide an absolute path to the configuration file when starting a controller/broker process. Also, the configuration file has to be provided as the last argument.
Compatibility, Deprecation, and Migration Plan
Existing users won't need to change any behavior if they want to continue killing both controller/broker processes. Otherwise, if they want to kill either the broker or controller, they'll need to specify a "process-role" field in the script.
Test Plan
The change can be tested through command line.