@@ -20,7 +20,9 @@ import (
2020 "flag"
2121 etcd "github.com/UffizziCloud/uffizzi-cluster-operator/controllers/etcd"
2222 "github.com/UffizziCloud/uffizzi-cluster-operator/controllers/uffizzicluster"
23+ "k8s.io/utils/pointer"
2324 "os"
25+ ctrlcfg "sigs.k8s.io/controller-runtime/pkg/config/v1alpha1"
2426
2527 // Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
2628 // to ensure that exec-entrypoint and run can make use of them.
@@ -56,14 +58,19 @@ func init() {
5658}
5759
5860func main () {
59- var metricsAddr string
60- var enableLeaderElection bool
61- var probeAddr string
61+ var (
62+ metricsAddr string
63+ probeAddr string
64+ enableLeaderElection bool
65+ concurrent int
66+ )
67+
6268 flag .StringVar (& metricsAddr , "metrics-bind-address" , ":8080" , "The address the metric endpoint binds to." )
6369 flag .StringVar (& probeAddr , "health-probe-bind-address" , ":8081" , "The address the probe endpoint binds to." )
6470 flag .BoolVar (& enableLeaderElection , "leader-elect" , false ,
6571 "Enable leader election for controller manager. " +
6672 "Enabling this will ensure there is only one active controller manager." )
73+ flag .IntVar (& concurrent , "concurrent" , 5 , "The number of concurrent reconciles per controller." )
6774 opts := zap.Options {
6875 Development : true ,
6976 }
@@ -79,17 +86,12 @@ func main() {
7986 HealthProbeBindAddress : probeAddr ,
8087 LeaderElection : enableLeaderElection ,
8188 LeaderElectionID : "bfbf93f2.uffizzi.com" ,
82- // LeaderElectionReleaseOnCancel defines if the leader should step down voluntarily
83- // when the Manager ends. This requires the binary to immediately end when the
84- // Manager is stopped, otherwise, this setting is unsafe. Setting this significantly
85- // speeds up voluntary leader transitions as the new leader don't have to wait
86- // LeaseDuration time first.
87- //
88- // In the default scaffold provided, the program ends immediately after
89- // the manager stops, so would be fine to enable this option. However,
90- // if you are doing or is intended to do any operation such as perform cleanups
91- // after the manager stops then its usage might be unsafe.
92- // LeaderElectionReleaseOnCancel: true,
89+ Controller : ctrlcfg.ControllerConfigurationSpec {
90+ GroupKindConcurrency : map [string ]int {
91+ uclusteruffizzicomv1alpha1 .SchemaGroupVersion .WithKind ("UffizziCluster" ).String (): concurrent ,
92+ },
93+ RecoverPanic : pointer .Bool (true ),
94+ },
9395 })
9496 if err != nil {
9597 setupLog .Error (err , "unable to start manager" )
@@ -108,7 +110,7 @@ func main() {
108110 Client : mgr .GetClient (),
109111 Scheme : mgr .GetScheme (),
110112 }).SetupWithManager (mgr ); err != nil {
111- setupLog .Error (err , "unable to create controller" , "controller" , "UffizziCluster " )
113+ setupLog .Error (err , "unable to create controller" , "controller" , "UffizziClusterEtcd " )
112114 os .Exit (1 )
113115 }
114116 //+kubebuilder:scaffold:builder
0 commit comments