Skip to content

Commit

Permalink
Fix unnecessary keepalived switches due to unhealthy condition (#423)
Browse files Browse the repository at this point in the history
  • Loading branch information
dergeberl authored Oct 25, 2024
1 parent 609b3e0 commit 37f1061
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions controllers/yawollet/loadbalancer_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/go-logr/logr"
"golang.org/x/time/rate"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/tools/record"
"k8s.io/client-go/util/workqueue"
Expand Down Expand Up @@ -96,6 +97,14 @@ func (r *LoadBalancerReconciler) Reconcile(ctx context.Context, req ctrl.Request
return ctrl.Result{}, err
}

// Return error if relevant condition is not as expected, to reconcile with a backoff.
// This is needed to prevent unnecessary keepalived switches due to unhealthy conditions.
// It happens with the EnvoyUpToDate condition on a config change if envoy is taking "longer" to set the new snapshot.
ok, reason := helper.AreRelevantConditionsMet(lbm, metav1.Time{Time: time.Now().Add(-2 * r.RequeueDuration)}, false)
if !ok {
return ctrl.Result{}, fmt.Errorf("not all relevant conditions are met: %s", reason)
}

return ctrl.Result{RequeueAfter: r.RequeueDuration}, reconcileError
}

Expand Down

0 comments on commit 37f1061

Please sign in to comment.