Skip to content
This repository was archived by the owner on Mar 26, 2025. It is now read-only.

Commit 7fbe049

Browse files
committed
Add gracefull CC shutdown script to the deployment
1 parent e246266 commit 7fbe049

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

pkg/resources/cruisecontrol/deployment.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,21 @@ func (r *Reconciler) deployment(log logr.Logger, clientPass string) runtime.Obje
8989
Value: "-javaagent:/opt/jmx-exporter/jmx_prometheus.jar=9020:/etc/jmx-exporter/config.yaml",
9090
},
9191
},
92+
Lifecycle: &corev1.Lifecycle{
93+
PreStop: &corev1.Handler{
94+
Exec: &corev1.ExecAction{
95+
Command: []string{"bash", "-c", `
96+
SIGNAL=${SIGNAL:-TERM}
97+
PIDS=$(ps ax | grep -i 'cruise-control' | grep java | grep -v grep | awk '{print $1}')
98+
if [ -z "$PIDS" ]; then
99+
echo "No cruise-control to stop"
100+
exit 1
101+
else
102+
kill -s $SIGNAL $PIDS
103+
fi`},
104+
},
105+
},
106+
},
92107
Image: r.KafkaCluster.Spec.CruiseControlConfig.GetCCImage(),
93108
Ports: []corev1.ContainerPort{
94109
{

0 commit comments

Comments
 (0)