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

Added script code to enable debug on Cruise Control #10775

Merged
merged 2 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 32 additions & 8 deletions development-docs/DEBUGGING.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,16 @@ Start tailing the operator pod (to make sure it's waiting for the debugger to at
You can now start the remote debug session from your IDE.


## Remote debugging the Kafka Broker
## Remote debugging the Kafka Broker and Cruise Control

Kafka Broker pods are defined through the 'my-cluster-kafka' StatefulSet which is created by Strimzi Kafka Operator.
Kafka broker pods are defined through the StrimziPodSet custom resource which is created by Strimzi Kafka Operator.
Cruise Control pods are created by using a Deployment resource instead.

In order to activate the remote debugging we need to get the Kafka Broker to run with remote debugging agent activated.
In order to activate the remote debugging we need to get the Kafka broker or Cruise Control to run with remote debugging agent activated.

This can be achieved by adding the following to your Kafka CR cluster definition:
For Kafka broker, this can be achieved by adding the following to your Kafka CR cluster definition under the `spec.kafka` field:

```

spec:
kafka:
...
Expand All @@ -86,7 +86,27 @@ spec:
value: "y"
- name: JAVA_DEBUG_PORT
value: "5005"
```

A similar configuration can be used to enable remote debugging for Cruise Control by adding the following to your Kafka CR cluster definition under the `spec.cruiseControl` field:

```
spec:
cruiseControl:
...

livenessProbe:
initialDelaySeconds: 3600
timeoutSeconds: 3600
template:
cruiseControlContainer:
env:
- name: KAFKA_DEBUG
value: "y"
- name: DEBUG_SUSPEND_FLAG
value: "y"
- name: JAVA_DEBUG_PORT
value: "5005"
```

We also need to open the specified port (5005 in this case) to be reachable from your host machine:
Expand All @@ -97,13 +117,17 @@ If you want to map to a different local port use the LOCAL:REMOTE format, for ex

kubectl port-forward my-cluster-kafka-0 8787:5005

The same applies for Cruise Control by using the Deployment:

kubectl port-forward deployments/my-cluster-cruise-control 5005

All you now have to do is deploy the new Kafka cluster definition, configure remote debugging in your favourite IDE, telling it to connect to localhost:5005, and start your debug session.

With `DEBUG_SUSPEND_FLAG` set to 'y', the Kafka Broker process will wait during startup for remote debugger (IDE) to connect before continuing with JVM start up.
With `DEBUG_SUSPEND_FLAG` set to 'y', the Kafka Broker or Cruise Control process will wait during startup for remote debugger (IDE) to connect before continuing with JVM start up.

In Kafka CR we have adjusted the probes to prevent Kubernetes from killing the broker whose execution is suspended due to a breakpoint.
In Kafka CR we have adjusted the probes to prevent Kubernetes from killing the broker or cruise control whose execution is suspended due to a breakpoint.

Before remotely connecting with your IDE you'll want to start tailing the `my-cluster-kafka-0` broker pod:
Before remotely connecting with your IDE you'll want to start tailing the `my-cluster-kafka-0` broker pod or the corresponding Cruise Control pod:

kubectl logs my-cluster-kafka-0 -f

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,26 @@ if [ "$CRUISE_CONTROL_METRICS_ENABLED" = "true" ]; then
export KAFKA_OPTS
fi

# Set Debug options if enabled
if [ "x$KAFKA_DEBUG" != "x" ]; then

# Use default ports
DEFAULT_JAVA_DEBUG_PORT="5005"

if [ -z "$JAVA_DEBUG_PORT" ]; then
JAVA_DEBUG_PORT="$DEFAULT_JAVA_DEBUG_PORT"
fi

# Use the defaults if JAVA_DEBUG_OPTS was not set
DEFAULT_JAVA_DEBUG_OPTS="-agentlib:jdwp=transport=dt_socket,server=y,suspend=${DEBUG_SUSPEND_FLAG:-n},address=$JAVA_DEBUG_PORT"
if [ -z "$JAVA_DEBUG_OPTS" ]; then
JAVA_DEBUG_OPTS="$DEFAULT_JAVA_DEBUG_OPTS"
fi

echo "Enabling Java debug options: $JAVA_DEBUG_OPTS"
KAFKA_OPTS="$JAVA_DEBUG_OPTS $KAFKA_OPTS"
fi

# Configure heap based on the available resources if needed
. ./dynamic_resources.sh

Expand Down
Loading