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

Commit 89abda2

Browse files
committed
Handle toleration causing unnecessary updates because of objectmatcher
1 parent 3113cf6 commit 89abda2

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

pkg/resources/kafka/kafka.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,19 @@ func (r *Reconciler) reconcileKafkaPod(log logr.Logger, desiredPod *corev1.Pod)
503503
}
504504
// TODO check if this err == nil check necessary (baluchicken)
505505
if err == nil {
506+
//Since toleration does not support patchStrategy:"merge,retainKeys", we need to add all toleration from the current pod if the toleration is set in the CR
507+
if len(desiredPod.Spec.Tolerations) > 0 {
508+
desiredPod.Spec.Tolerations = append(desiredPod.Spec.Tolerations, currentPod.Spec.Tolerations...)
509+
uniqueTolerations := []corev1.Toleration{}
510+
keys := make(map[corev1.Toleration]bool)
511+
for _, t := range desiredPod.Spec.Tolerations {
512+
if _, value := keys[t]; !value {
513+
keys[t] = true
514+
uniqueTolerations = append(uniqueTolerations, t)
515+
}
516+
}
517+
desiredPod.Spec.Tolerations = uniqueTolerations
518+
}
506519
// Check if the resource actually updated
507520
patchResult, err := patch.DefaultPatchMaker.Calculate(currentPod, desiredPod)
508521
if err != nil {

0 commit comments

Comments
 (0)