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

Some broker pods get stuck caused by a terminated container when there is no healthy broker in the kafka cluster. #802

Merged
merged 5 commits into from
May 5, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 17 additions & 2 deletions pkg/resources/kafka/kafka.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ func getLoadBalancerIP(foundLBService *corev1.Service) (string, error) {
}

// Reconcile implements the reconcile logic for Kafka
//gocyclo:ignore
func (r *Reconciler) Reconcile(log logr.Logger) error {
log = log.WithValues("component", componentName, "clusterName", r.KafkaCluster.Name, "clusterNamespace", r.KafkaCluster.Namespace)

Expand Down Expand Up @@ -242,6 +243,7 @@ func (r *Reconciler) Reconcile(log logr.Logger) error {
}

reorderedBrokers := reorderBrokers(brokerPods, r.KafkaCluster.Spec.Brokers, r.KafkaCluster.Status.BrokersState, controllerID)
allBrokerDynamicConfigSucceeded := true
for _, broker := range reorderedBrokers {
brokerConfig, err := broker.GetBrokerConfig(r.KafkaCluster.Spec)
if err != nil {
Expand Down Expand Up @@ -285,11 +287,24 @@ func (r *Reconciler) Reconcile(log logr.Logger) error {
if err = r.updateStatusWithDockerImageAndVersion(broker.Id, brokerConfig, log); err != nil {
return err
}
if err = r.reconcilePerBrokerDynamicConfig(broker.Id, brokerConfig, configMap, log); err != nil {
return err
// If dynamic configs can not be set then let the loop continue to the next broker,
// after the loop we return error. This solve that case when other brokers could get healthy,
// but the loop exits too soon because dynamic configs can not be set.
err = r.reconcilePerBrokerDynamicConfig(broker.Id, brokerConfig, configMap, log)
if err != nil {
log.Error(err, "setting dynamic configs has failed", "brokerID", broker.Id)
allBrokerDynamicConfigSucceeded = false
}
}

if !allBrokerDynamicConfigSucceeded {
// re-reconcile to retry setting the dynamic configs
return errors.NewWithDetails("setting dynamic configs for some brokers has failed",
"component", componentName,
"clusterName", r.KafkaCluster.Name,
"clusterNamespace", r.KafkaCluster.Namespace)
}

if err = r.reconcileClusterWideDynamicConfig(); err != nil {
return err
}
Expand Down