Skip to content

Commit

Permalink
fix: apisix_upstream sync panic (#1192)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlinsRan committed Jul 28, 2022
1 parent 6cc718b commit 2cc586b
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions pkg/ingress/apisix_upstream.go
Expand Up @@ -442,19 +442,27 @@ 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
}
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(),
},
})
}
}

0 comments on commit 2cc586b

Please sign in to comment.