From 0fc10ae615fd132c878ee6ac79d1cae6c0bdf4d4 Mon Sep 17 00:00:00 2001 From: Arnob kumar saha Date: Thu, 11 Jul 2024 20:58:07 +0600 Subject: [PATCH] wip Signed-off-by: Arnob kumar saha --- pkg/cmds/webhook.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pkg/cmds/webhook.go b/pkg/cmds/webhook.go index 06c09b94..293de1c3 100644 --- a/pkg/cmds/webhook.go +++ b/pkg/cmds/webhook.go @@ -29,6 +29,7 @@ import ( "k8s.io/apimachinery/pkg/types" clientscheme "k8s.io/client-go/kubernetes/scheme" _ "k8s.io/client-go/plugin/pkg/client/auth" + "k8s.io/klog/v2" "k8s.io/klog/v2/klogr" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" @@ -102,8 +103,11 @@ func NewCmdWebhook(ctx context.Context) *cobra.Command { os.Exit(1) } + klog.Info("mgr.Add()") if err := mgr.Add(manager.RunnableFunc(func(ctx context.Context) error { + klog.Info("Inside mgr.Add()") if mgr.GetCache().WaitForCacheSync(context.TODO()) { + klog.Info("cache is synced") if err := updateMutatingWebhookCABundle(mgr, webhookName, certDir); err != nil { setupLog.Error(err, "unable to update caBundle for MutatingWebhookConfiguration") os.Exit(1) @@ -118,6 +122,7 @@ func NewCmdWebhook(ctx context.Context) *cobra.Command { setupLog.Error(err, "unable to setup webhook configuration updater") os.Exit(1) } + // mgr.GetCache().WaitForCacheSync(context.TODO()) setupLog.Info("starting manager") if err := mgr.Start(ctx); err != nil { @@ -165,5 +170,7 @@ func updateValidatingWebhookCABundle(mgr ctrl.Manager, name, certDir string) err for i := range webhook.Webhooks { webhook.Webhooks[i].ClientConfig.CABundle = caBundle } - return mgr.GetClient().Update(context.TODO(), webhook, &client.UpdateOptions{}) + err = mgr.GetClient().Update(context.TODO(), webhook, &client.UpdateOptions{}) + klog.Infof("Updating validating webhook caBundle to %s", caBundle) + return err }