Skip to content

Commit

Permalink
Ensure webhook is started
Browse files Browse the repository at this point in the history
This ensures webhook is started when controller-manage deployment
becomes ready.
  • Loading branch information
kajinamit committed Aug 7, 2023
1 parent 07f07cd commit 471a781
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ func main() {
// Acquire environmental defaults and initialize operator defaults with them
mariadbv1beta1.SetupDefaults()

checker := healthz.Ping
// Setup webhooks if requested
if strings.ToLower(os.Getenv("ENABLE_WEBHOOKS")) != "false" {
if err = (&mariadbv1beta1.MariaDB{}).SetupWebhookWithManager(mgr); err != nil {
Expand All @@ -133,15 +134,16 @@ func main() {
setupLog.Error(err, "unable to create webhook", "webhook", "Galera")
os.Exit(1)
}
checker = mgr.GetWebhookServer().StartedChecker()
}

//+kubebuilder:scaffold:builder

if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil {
if err := mgr.AddHealthzCheck("healthz", checker); err != nil {
setupLog.Error(err, "unable to set up health check")
os.Exit(1)
}
if err := mgr.AddReadyzCheck("readyz", healthz.Ping); err != nil {
if err := mgr.AddReadyzCheck("readyz", checker); err != nil {
setupLog.Error(err, "unable to set up ready check")
os.Exit(1)
}
Expand Down

0 comments on commit 471a781

Please sign in to comment.