From f239b89642955e134c54cff075840801ebba2517 Mon Sep 17 00:00:00 2001 From: Jan Kantert Date: Mon, 15 Jul 2024 13:25:19 +0200 Subject: [PATCH] increase LeaseDuration and RenewDeadline and turn them into an option Signed-off-by: Jan Kantert Co-authored-by: Erik Godding Boye --- cmd/trust-manager/app/app.go | 2 ++ cmd/trust-manager/app/options/options.go | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/cmd/trust-manager/app/app.go b/cmd/trust-manager/app/app.go index 711e0b1d..74c6b959 100644 --- a/cmd/trust-manager/app/app.go +++ b/cmd/trust-manager/app/app.go @@ -80,6 +80,8 @@ func NewCommand() *cobra.Command { LeaderElection: true, LeaderElectionID: "trust-manager-leader-election", LeaderElectionReleaseOnCancel: true, + LeaseDuration: &opts.LeaseDuration, + RenewDeadline: &opts.RenewDeadline, ReadinessEndpointName: opts.ReadyzPath, HealthProbeBindAddress: fmt.Sprintf("0.0.0.0:%d", opts.ReadyzPort), WebhookServer: ctrlwebhook.NewServer(ctrlwebhook.Options{ diff --git a/cmd/trust-manager/app/options/options.go b/cmd/trust-manager/app/options/options.go index ea8f3c84..baf6ea4b 100644 --- a/cmd/trust-manager/app/options/options.go +++ b/cmd/trust-manager/app/options/options.go @@ -21,6 +21,7 @@ import ( "fmt" "log/slog" "os" + "time" "github.com/go-logr/logr" "github.com/spf13/cobra" @@ -63,6 +64,12 @@ type Options struct { // log are options controlling logging log logOptions + + // Leader election lease duration + LeaseDuration time.Duration + + // Leader election lease renew duration + RenewDeadline time.Duration } type logOptions struct { @@ -187,6 +194,14 @@ func (o *Options) addAppFlags(fs *pflag.FlagSet) { "readiness-probe-path", "/readyz", "HTTP path to expose the readiness probe server.") + fs.DurationVar(&o.LeaseDuration, + "leader-election-lease-duration", time.Second*15, + "Lease duration for leader election") + + fs.DurationVar(&o.RenewDeadline, + "leader-election-renew-deadline", time.Second*10, + "Lease renew deadline for leader election") + fs.IntVar(&o.MetricsPort, "metrics-port", 9402, "Port to expose Prometheus metrics on 0.0.0.0 on path '/metrics'.")