Skip to content

Commit e242bb0

Browse files
committed
Allow overriding ctrl manager graceful shutdown timeout
Overriding the default GracefulShutdownTimeout option given to the controller manager with a default of 0 (no timeout) since the helm operations are sensitive to interruption and can lead to leaving the HelmRelease in a bad state. This will also allow users to override the option via a cli flag `-graceful-shutdown-timeout` how much time to wait before forcibly exiting. Related to #569 Signed-off-by: Aurel Canciu <aurelcanciu@gmail.com>
1 parent 8d1afa6 commit e242bb0

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

main.go

+16-13
Original file line numberDiff line numberDiff line change
@@ -64,26 +64,28 @@ func init() {
6464

6565
func main() {
6666
var (
67-
metricsAddr string
68-
eventsAddr string
69-
healthAddr string
70-
concurrent int
71-
requeueDependency time.Duration
72-
watchAllNamespaces bool
73-
httpRetry int
74-
clientOptions client.Options
75-
kubeConfigOpts client.KubeConfigOptions
76-
logOptions logger.Options
77-
aclOptions acl.Options
78-
leaderElectionOptions leaderelection.Options
79-
rateLimiterOptions helper.RateLimiterOptions
67+
metricsAddr string
68+
eventsAddr string
69+
healthAddr string
70+
concurrent int
71+
requeueDependency time.Duration
72+
gracefulShutdownTimeout time.Duration
73+
watchAllNamespaces bool
74+
httpRetry int
75+
clientOptions client.Options
76+
kubeConfigOpts client.KubeConfigOptions
77+
logOptions logger.Options
78+
aclOptions acl.Options
79+
leaderElectionOptions leaderelection.Options
80+
rateLimiterOptions helper.RateLimiterOptions
8081
)
8182

8283
flag.StringVar(&metricsAddr, "metrics-addr", ":8080", "The address the metric endpoint binds to.")
8384
flag.StringVar(&eventsAddr, "events-addr", "", "The address of the events receiver.")
8485
flag.StringVar(&healthAddr, "health-addr", ":9440", "The address the health endpoint binds to.")
8586
flag.IntVar(&concurrent, "concurrent", 4, "The number of concurrent HelmRelease reconciles.")
8687
flag.DurationVar(&requeueDependency, "requeue-dependency", 30*time.Second, "The interval at which failing dependencies are reevaluated.")
88+
flag.DurationVar(&gracefulShutdownTimeout, "graceful-shutdown-timeout", 0, "The duration given to the reconciler to finish before forcibly stopping.")
8789
flag.BoolVar(&watchAllNamespaces, "watch-all-namespaces", true,
8890
"Watch for custom resources in all namespaces, if set to false it will only watch the runtime namespace.")
8991
flag.IntVar(&httpRetry, "http-retry", 9, "The maximum number of retries when failing to fetch artifacts over HTTP.")
@@ -120,6 +122,7 @@ func main() {
120122
LeaseDuration: &leaderElectionOptions.LeaseDuration,
121123
RenewDeadline: &leaderElectionOptions.RenewDeadline,
122124
RetryPeriod: &leaderElectionOptions.RetryPeriod,
125+
GracefulShutdownTimeout: &gracefulShutdownTimeout,
123126
LeaderElectionID: fmt.Sprintf("%s-leader-election", controllerName),
124127
Namespace: watchNamespace,
125128
Logger: ctrl.Log,

0 commit comments

Comments
 (0)