From 36bbc6a2e2d5ad697542efa68e6304e0fb711aa4 Mon Sep 17 00:00:00 2001 From: Kevin Wan Date: Mon, 23 Oct 2023 21:57:09 +0800 Subject: [PATCH] chore: add error handling on registering event handlers to k8s (#3663) --- zrpc/resolver/internal/kubebuilder.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/zrpc/resolver/internal/kubebuilder.go b/zrpc/resolver/internal/kubebuilder.go index 38c1f775..2392cc67 100644 --- a/zrpc/resolver/internal/kubebuilder.go +++ b/zrpc/resolver/internal/kubebuilder.go @@ -68,7 +68,11 @@ func (b *kubeBuilder) Build(target resolver.Target, cc resolver.ClientConn, options.FieldSelector = nameSelector + svc.Name })) in := inf.Core().V1().Endpoints() - in.Informer().AddEventHandler(handler) + _, err = in.Informer().AddEventHandler(handler) + if err != nil { + return nil, err + } + threading.GoSafe(func() { inf.Start(proc.Done()) }) @@ -76,6 +80,7 @@ func (b *kubeBuilder) Build(target resolver.Target, cc resolver.ClientConn, if err != nil { return nil, err } + handler.Update(endpoints) return &nopResolver{cc: cc}, nil