Skip to content

Commit 079fe5a

Browse files
committed
add pre-stop sleep hook to controller kafka container
1 parent a8b71fe commit 079fe5a

1 file changed

Lines changed: 17 additions & 3 deletions

File tree

rust/operator-binary/src/resource/statefulset.rs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ use stackable_operator::{
2323
apps::v1::{StatefulSet, StatefulSetSpec, StatefulSetUpdateStrategy},
2424
core::v1::{
2525
ConfigMapKeySelector, ConfigMapVolumeSource, ContainerPort, EnvVar, EnvVarSource,
26-
ExecAction, ObjectFieldSelector, PodSpec, Probe, ServiceAccount, TCPSocketAction,
27-
Volume,
26+
ExecAction, Lifecycle, LifecycleHandler, ObjectFieldSelector, PodSpec, Probe,
27+
ServiceAccount, SleepAction, TCPSocketAction, Volume,
2828
},
2929
},
3030
apimachinery::pkg::{apis::meta::v1::LabelSelector, util::intstr::IntOrString},
@@ -756,10 +756,24 @@ pub fn build_controller_rolegroup_statefulset(
756756
)
757757
.context(AddVolumesAndVolumeMountsSnafu)?;
758758

759+
// Currently, Controllers shutdown very fast, too fast in most times (flakyness) for the Brokers
760+
// to off load properly. The Brokers then try to connect to any controllers until the
761+
// `gracefulShutdownTimeout` is reached and the pod is finally killed.
762+
// The `pre-stop` hook will delay the kill signal to the Controllers to provide the Brokers more
763+
// time to offload data.
764+
let mut kafka_container = cb_kafka.build();
765+
kafka_container.lifecycle = Some(Lifecycle {
766+
pre_stop: Some(LifecycleHandler {
767+
sleep: Some(SleepAction { seconds: 10 }),
768+
..Default::default()
769+
}),
770+
..Default::default()
771+
});
772+
759773
pod_builder
760774
.metadata(metadata)
761775
.image_pull_secrets_from_product_image(resolved_product_image)
762-
.add_container(cb_kafka.build())
776+
.add_container(kafka_container)
763777
.affinity(&merged_config.affinity)
764778
.add_volume(Volume {
765779
name: "config".to_string(),

0 commit comments

Comments
 (0)