Skip to content

Commit

Permalink
Suggested configuration fix for the KLM leaderElection process
Browse files Browse the repository at this point in the history
  • Loading branch information
medmes committed Dec 23, 2024
1 parent 4210b9e commit b077188
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
3 changes: 2 additions & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func pprofStartServer(addr string, timeout time.Duration, setupLog logr.Logger)
}
}

func setupManager(flagVar *flags.FlagVar, cacheOptions cache.Options, scheme *machineryruntime.Scheme, setupLog logr.Logger) { //nolint: funlen // setupManager is a main function that sets up the manager
func setupManager(flagVar *flags.FlagVar, cacheOptions cache.Options, scheme *machineryruntime.Scheme, setupLog logr.Logger) { // nolint: funlen // setupManager is a main function that sets up the manager

Check failure on line 141 in cmd/main.go

View workflow job for this annotation

GitHub Actions / lint

directive `// nolint: funlen // setupManager is a main function that sets up the manager` should be written without leading space as `//nolint: funlen // setupManager is a main function that sets up the manager` (nolintlint)
config := ctrl.GetConfigOrDie()
config.QPS = float32(flagVar.ClientQPS)
config.Burst = flagVar.ClientBurst
Expand All @@ -154,6 +154,7 @@ func setupManager(flagVar *flags.FlagVar, cacheOptions cache.Options, scheme *ma
LeaderElectionID: "893110f7.kyma-project.io",
LeaseDuration: &flagVar.LeaderElectionLeaseDuration,
RenewDeadline: &flagVar.LeaderElectionRenewDeadline,
RetryPeriod: &flagVar.LeaderElectionRetryPeriod,
Cache: cacheOptions,
},
)
Expand Down
9 changes: 7 additions & 2 deletions internal/pkg/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,9 @@ const (
DefaultWatcherResourceLimitsMemory = "200Mi"
DefaultDropCrdStoredVersionMap = "Manifest:v1beta1,Watcher:v1beta1,ModuleTemplate:v1beta1,Kyma:v1beta1"
DefaultMetricsCleanupIntervalInMinutes = 15
DefaultLeaderElectionLeaseDuration = 180 * time.Second
DefaultLeaderElectionRenewDeadline = 120 * time.Second
DefaultLeaderElectionLeaseDuration = 20 * time.Second
DefaultLeaderElectionRenewDeadline = 15 * time.Second
DefaultLeaderElectionRetryPeriod = 3 * time.Second
)

var (
Expand Down Expand Up @@ -112,6 +113,9 @@ func DefineFlagVar() *FlagVar {
flag.DurationVar(&flagVar.LeaderElectionRenewDeadline, "leader-election-renew-deadline",
DefaultLeaderElectionRenewDeadline,
"Configures the 'RenewDeadline' option of the controller-runtime library used to run the controller manager process.")
flag.DurationVar(&flagVar.LeaderElectionRetryPeriod, "leader-election-retry-period",
DefaultLeaderElectionRetryPeriod,
"configures the 'RetryPeriod' option of the controller-runtime library used to run the controller manager process.")
flag.DurationVar(&flagVar.KymaRequeueSuccessInterval, "kyma-requeue-success-interval",
DefaultKymaRequeueSuccessInterval,
"determines the duration a Kyma in Ready state is enqueued for reconciliation.")
Expand Down Expand Up @@ -242,6 +246,7 @@ type FlagVar struct {
EnableLeaderElection bool
LeaderElectionLeaseDuration time.Duration
LeaderElectionRenewDeadline time.Duration
LeaderElectionRetryPeriod time.Duration
EnablePurgeFinalizer bool
EnableKcpWatcher bool
EnableWebhooks bool
Expand Down
9 changes: 7 additions & 2 deletions internal/pkg/flags/flags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,12 +253,17 @@ func Test_ConstantFlags(t *testing.T) {
{
constName: "DefaultLeaderElectionLeaseDuration",
constValue: DefaultLeaderElectionLeaseDuration.String(),
expectedValue: (180 * time.Second).String(),
expectedValue: (20 * time.Second).String(),
},
{
constName: "DefaultLeaderElectionRenewDeadline",
constValue: DefaultLeaderElectionRenewDeadline.String(),
expectedValue: (120 * time.Second).String(),
expectedValue: (15 * time.Second).String(),
},
{
constName: "DefaultLeaderElectionRetryPeriod",
constValue: DefaultLeaderElectionRetryPeriod.String(),
expectedValue: (3 * time.Second).String(),
},
}
for _, testcase := range tests {
Expand Down

0 comments on commit b077188

Please sign in to comment.