This is an automated email from the ASF dual-hosted git repository.

wmedvedeo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-kie-tools.git


The following commit(s) were added to refs/heads/main by this push:
     new 030e01865aa kie-tools-3364: [sonataflow-operator] Add the ability to 
configure the leader lease parameters (#3365)
030e01865aa is described below

commit 030e01865aa5dd4e109481809f7cc70eef640354
Author: Walter Medvedeo <[email protected]>
AuthorDate: Fri Nov 28 08:56:01 2025 +0100

    kie-tools-3364: [sonataflow-operator] Add the ability to configure the 
leader lease parameters (#3365)
---
 packages/sonataflow-operator/cmd/main.go           | 37 +++++++++++++++++++++-
 .../config/default/manager_auth_proxy_patch.yaml   |  5 +++
 packages/sonataflow-operator/operator.yaml         |  5 +++
 3 files changed, 46 insertions(+), 1 deletion(-)

diff --git a/packages/sonataflow-operator/cmd/main.go 
b/packages/sonataflow-operator/cmd/main.go
index 4a20800223a..470eebfb1b9 100644
--- a/packages/sonataflow-operator/cmd/main.go
+++ b/packages/sonataflow-operator/cmd/main.go
@@ -24,6 +24,7 @@ import (
        "flag"
        "fmt"
        "os"
+       "time"
 
        
"github.com/apache/incubator-kie-tools/packages/sonataflow-operator/api/version"
 
@@ -80,6 +81,11 @@ func init() {
 func main() {
        var metricsAddr string
        var enableLeaderElection bool
+       var leaseDuration *time.Duration
+       var renewDeadline *time.Duration
+       var retryPeriod *time.Duration
+       var qps *float64
+       var burst *int
        var probeAddr string
        var secureMetrics bool
        var enableHTTP2 bool
@@ -90,6 +96,19 @@ func main() {
        flag.BoolVar(&enableLeaderElection, "leader-elect", false,
                "Enable leader election for controller manager. "+
                        "Enabling this will ensure there is only one active 
controller manager.")
+       // Flags for leader election tuning, resilient default values for 
production.
+       leaseDuration = flag.Duration("lease-duration", 60*time.Second, "Leader 
election lease duration")
+       renewDeadline = flag.Duration("renew-deadline", 40*time.Second, "Leader 
election renew deadline")
+       retryPeriod = flag.Duration("retry-period", 15*time.Second, "Leader 
election retry period")
+
+       // Flags for tuning client-go throttling
+       // 20 / 50      Very light operators
+       // 50 / 100     General-purpose OLM operators
+       // 100 / 200    Operators managing many CRDs or watching many namespaces
+       // 200 / 400    Extremely chatty operators (cluster-wide + many 
controllers)
+       qps = flag.Float64("qps", 50, "Maximum average QPS for Kubernetes 
client-go")
+       burst = flag.Int("burst", 100, "Maximum burst for Kubernetes client-go")
+
        flag.BoolVar(&secureMetrics, "metrics-secure", false,
                "If set the metrics endpoint is served securely")
        flag.BoolVar(&enableHTTP2, "enable-http2", false,
@@ -97,6 +116,16 @@ func main() {
        flag.StringVar(&controllerCfgPath, "controller-cfg-path", "", "The 
controller config file path.")
        flag.Parse()
 
+       klog.InfoS("leader election configuration",
+               "leader-elect", enableLeaderElection,
+               "lease-duration", leaseDuration,
+               "renew-deadline", renewDeadline,
+               "retry-period", retryPeriod)
+
+       klog.InfoS("client-go throttling configuration",
+               "qps", qps,
+               "burst", burst)
+
        manager.SetOperatorStartTime()
 
        ctrl.SetLogger(klogr.New().WithName(controller.ComponentName))
@@ -121,7 +150,10 @@ func main() {
                TLSOpts: tlsOpts,
        })
 
-       mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
+       config := ctrl.GetConfigOrDie()
+       config.QPS = float32(*qps)
+       config.Burst = *burst
+       mgr, err := ctrl.NewManager(config, ctrl.Options{
                Scheme: scheme,
                Metrics: metricsserver.Options{
                        BindAddress:   metricsAddr,
@@ -143,6 +175,9 @@ func main() {
                // if you are doing or is intended to do any operation such as 
perform cleanups
                // after the manager stops then its usage might be unsafe.
                // LeaderElectionReleaseOnCancel: true,
+               LeaseDuration: leaseDuration,
+               RenewDeadline: renewDeadline,
+               RetryPeriod:   retryPeriod,
        })
        if err != nil {
                klog.V(log.E).ErrorS(err, "unable to start manager")
diff --git 
a/packages/sonataflow-operator/config/default/manager_auth_proxy_patch.yaml 
b/packages/sonataflow-operator/config/default/manager_auth_proxy_patch.yaml
index 9b1113b5150..4506f8a6d55 100644
--- a/packages/sonataflow-operator/config/default/manager_auth_proxy_patch.yaml
+++ b/packages/sonataflow-operator/config/default/manager_auth_proxy_patch.yaml
@@ -59,4 +59,9 @@ spec:
             - "--health-probe-bind-address=:8081"
             - "--metrics-bind-address=127.0.0.1:8080"
             - "--leader-elect"
+            - "--lease-duration=60s"
+            - "--renew-deadline=40s"
+            - "--retry-period=15s"
+            - "--qps=50"
+            - "--burst=100"
             - "--v=0"
diff --git a/packages/sonataflow-operator/operator.yaml 
b/packages/sonataflow-operator/operator.yaml
index da7ea17fb84..f7a080de171 100644
--- a/packages/sonataflow-operator/operator.yaml
+++ b/packages/sonataflow-operator/operator.yaml
@@ -28314,6 +28314,11 @@ spec:
             - --health-probe-bind-address=:8081
             - --metrics-bind-address=127.0.0.1:8080
             - --leader-elect
+            - --lease-duration=60s
+            - --renew-deadline=40s
+            - --retry-period=15s
+            - --qps=50
+            - --burst=100
             - --v=0
           command:
             - /usr/local/bin/manager


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to