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

Add flags to configure LeaseDuration and RenewDeadline #385

Merged
merged 1 commit into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cmd/trust-manager/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
15 changes: 15 additions & 0 deletions cmd/trust-manager/app/options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"fmt"
"log/slog"
"os"
"time"

"github.com/go-logr/logr"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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'.")
Expand Down