This is an automated email from the ASF dual-hosted git repository.

zhangjintao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix-ingress-controller.git


The following commit(s) were added to refs/heads/master by this push:
     new 2cc586bb fix: apisix_upstream sync panic (#1192)
2cc586bb is described below

commit 2cc586bbe06d3dd4c1c904fd487a9eaa13b5b3a2
Author: Xin Rong <[email protected]>
AuthorDate: Thu Jul 28 12:47:59 2022 +0800

    fix: apisix_upstream sync panic (#1192)
---
 pkg/ingress/apisix_upstream.go | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/pkg/ingress/apisix_upstream.go b/pkg/ingress/apisix_upstream.go
index d5fb3e1e..526ba977 100644
--- a/pkg/ingress/apisix_upstream.go
+++ b/pkg/ingress/apisix_upstream.go
@@ -442,9 +442,9 @@ func (c *apisixUpstreamController) onDelete(obj 
interface{}) {
 }
 
 func (c *apisixUpstreamController) ResourceSync() {
-       clusterConfigs := 
c.controller.apisixUpstreamInformer.GetIndexer().List()
-       for _, clusterConfig := range clusterConfigs {
-               key, err := cache.MetaNamespaceKeyFunc(clusterConfig)
+       objs := c.controller.apisixUpstreamInformer.GetIndexer().List()
+       for _, obj := range objs {
+               key, err := cache.MetaNamespaceKeyFunc(obj)
                if err != nil {
                        log.Errorw("ApisixUpstream sync failed, found 
ApisixUpstream resource with bad meta namespace key", zap.String("error", 
err.Error()))
                        continue
@@ -452,9 +452,17 @@ func (c *apisixUpstreamController) ResourceSync() {
                if !c.controller.isWatchingNamespace(key) {
                        continue
                }
+               au, err := kube.NewApisixUpstream(obj)
+               if err != nil {
+                       log.Errorw("ApisixUpstream sync failed, found 
ApisixUpstream resource with bad type", zap.Error(err))
+                       return
+               }
                c.workqueue.Add(&types.Event{
-                       Type:   types.EventAdd,
-                       Object: key,
+                       Type: types.EventAdd,
+                       Object: kube.ApisixUpstreamEvent{
+                               Key:          key,
+                               GroupVersion: au.GroupVersion(),
+                       },
                })
        }
 }

Reply via email to