From dccd9c8fcd88ad253d6e3a8d8a95fea60d7029e4 Mon Sep 17 00:00:00 2001 From: Jigisha Patil <89548848+jigisha620@users.noreply.github.com> Date: Tue, 27 Aug 2024 11:58:56 -0700 Subject: [PATCH] chore: Add readiness check on cache sync (#1593) --- pkg/operator/operator.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/operator/operator.go b/pkg/operator/operator.go index d961bae22f..5e425dbe01 100644 --- a/pkg/operator/operator.go +++ b/pkg/operator/operator.go @@ -204,7 +204,9 @@ func NewOperator() (context.Context, *Operator) { lo.Must0(mgr.GetFieldIndexer().IndexField(ctx, &storagev1.VolumeAttachment{}, "spec.nodeName", func(o client.Object) []string { return []string{o.(*storagev1.VolumeAttachment).Spec.NodeName} }), "failed to setup volumeattachment indexer") - + lo.Must0(mgr.AddReadyzCheck("manager", func(req *http.Request) error { + return lo.Ternary(mgr.GetCache().WaitForCacheSync(req.Context()), nil, fmt.Errorf("failed to sync caches")) + })) lo.Must0(mgr.AddHealthzCheck("healthz", healthz.Ping)) lo.Must0(mgr.AddReadyzCheck("readyz", healthz.Ping))