-
Notifications
You must be signed in to change notification settings - Fork 19
Configurable DrainerTimeout #152
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,6 +24,7 @@ import ( | |
| "os" | ||
| "path/filepath" | ||
| "runtime" | ||
| "time" | ||
|
|
||
| "github.com/medik8s/common/pkg/lease" | ||
| "go.uber.org/zap/zapcore" | ||
|
|
@@ -52,7 +53,7 @@ const ( | |
| WebhookCertDir = "/apiserver.local.config/certificates" | ||
| WebhookCertName = "apiserver.crt" | ||
| WebhookKeyName = "apiserver.key" | ||
| operatorName = "NodeMaintenance" | ||
| operatorName = "NodeMaintenance" | ||
| ) | ||
|
|
||
| var ( | ||
|
|
@@ -69,16 +70,24 @@ func init() { | |
|
|
||
| func main() { | ||
| var ( | ||
| metricsAddr, probeAddr string | ||
| metricsAddr, probeAddr string | ||
| enableLeaderElection, enableHTTP2 bool | ||
| webhookOpts webhook.Options | ||
| ) | ||
| webhookOpts webhook.Options | ||
| drainerTimeout time.Duration | ||
| ) | ||
| flag.StringVar(&metricsAddr, "metrics-bind-address", ":8080", "The address the metric endpoint binds to.") | ||
| flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.") | ||
| flag.BoolVar(&enableLeaderElection, "leader-elect", false, | ||
| "Enable leader election for controller manager. "+ | ||
| "Enabling this will ensure there is only one active controller manager.") | ||
| flag.BoolVar(&enableHTTP2, "enable-http2", false, "If HTTP/2 should be enabled for the metrics and webhook servers.") | ||
| flag.DurationVar(&drainerTimeout, "drainer-timeout", controllers.DefaultDrainerTimeout, "Timeout for draining a node.") | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. would it make sense to check for reasonable values?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably not relevant to this PR, but this looks to me like something that would make sense to put in a configuration not ? |
||
|
|
||
| if drainerTimeout <= 0 { | ||
| setupLog.Error(fmt.Errorf("got non positive DrainerTimeout='%s'", drainerTimeout), "Invalid DrainerTimout") | ||
| os.Exit(1) | ||
| } | ||
| setupLog.Info(fmt.Sprintf("Using drainer timeout: %s", drainerTimeout)) | ||
|
|
||
| opts := zap.Options{ | ||
| Development: true, | ||
|
|
@@ -94,7 +103,7 @@ func main() { | |
| configureWebhookOpts(&webhookOpts, enableHTTP2) | ||
|
|
||
| mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{ | ||
| Scheme: scheme, | ||
| Scheme: scheme, | ||
| WebhookServer: webhook.NewServer(webhookOpts), | ||
| HealthProbeBindAddress: probeAddr, | ||
| LeaderElection: enableLeaderElection, | ||
|
|
@@ -105,31 +114,31 @@ func main() { | |
| os.Exit(1) | ||
| } | ||
|
|
||
|
|
||
| cl := mgr.GetClient() | ||
| leaseManagerInitializer := &leaseManagerInitializer{cl: cl} | ||
| if err := mgr.Add(leaseManagerInitializer); err != nil { | ||
| setupLog.Error(err, "unable to set up lease Manager", "lease", operatorName) | ||
| os.Exit(1) | ||
| } | ||
| openshiftCheck,err := utils.NewOpenshiftValidator(mgr.GetConfig()) | ||
|
|
||
| openshiftCheck, err := utils.NewOpenshiftValidator(mgr.GetConfig()) | ||
| if err != nil { | ||
| setupLog.Error(err, "failed to check if we run on Openshift") | ||
| os.Exit(1) | ||
| } | ||
| isOpenShift := openshiftCheck.IsOpenshiftSupported() | ||
| if isOpenShift{ | ||
| if isOpenShift { | ||
| setupLog.Info("NMO was installed on Openshift cluster") | ||
| } | ||
|
|
||
|
|
||
| if err = (&controllers.NodeMaintenanceReconciler{ | ||
| Client: cl, | ||
| Scheme: mgr.GetScheme(), | ||
| MgrConfig: mgr.GetConfig(), | ||
| LeaseManager: leaseManagerInitializer, | ||
| Recorder: mgr.GetEventRecorderFor(operatorName), | ||
| Recorder: mgr.GetEventRecorderFor(operatorName), | ||
|
|
||
| DrainerTimeout: drainerTimeout, | ||
| }).SetupWithManager(mgr); err != nil { | ||
| setupLog.Error(err, "unable to create controller", "controller", operatorName) | ||
| os.Exit(1) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.