gxthrj commented on a change in pull request #386: URL: https://github.com/apache/apisix-ingress-controller/pull/386#discussion_r617260925
########## File path: pkg/ingress/apisix_route.go ########## @@ -197,15 +208,57 @@ func (c *apisixRouteController) sync(ctx context.Context, ev *types.Event) error return c.controller.syncManifests(ctx, added, updated, deleted) } -func (c *apisixRouteController) handleSyncErr(obj interface{}, err error) { - if err == nil { +func (c *apisixRouteController) handleSyncErr(obj interface{}, errOrigin error) { + ev := obj.(*types.Event) + event := ev.Object.(kube.ApisixRouteEvent) + namespace, name, errLocal := cache.SplitMetaNamespaceKey(event.Key) + if errLocal != nil { + log.Errorf("invalid resource key: %s", event.Key) + } + if errOrigin == nil { + if ev.Type != types.EventDelete { + var ar kube.ApisixRoute + if event.GroupVersion == kube.ApisixRouteV1 { + ar, errLocal = c.controller.apisixRouteLister.V1(namespace, name) + } else { + ar, errLocal = c.controller.apisixRouteLister.V2alpha1(namespace, name) + } + if errLocal == nil { + message := fmt.Sprintf(_messageResourceSynced, _component) + if ar.GroupVersion() == kube.ApisixRouteV1 { + c.recorder.Event(ar.V1(), v1.EventTypeNormal, _resourceSynced, message) + } else if ar.GroupVersion() == kube.ApisixRouteV2alpha1 { + c.recorder.Event(ar.V2alpha1(), v1.EventTypeNormal, _resourceSynced, message) + RecordRouteStatus(ar.V2alpha1(), _resourceSynced, CommonSuccessMessage, metav1.ConditionTrue) + } + } else { + log.Errorf("invalid resource key: %s", event.Key) + } + } c.workqueue.Forget(obj) return } log.Warnw("sync ApisixRoute failed, will retry", zap.Any("object", obj), - zap.Error(err), + zap.Error(errOrigin), ) + var ar kube.ApisixRoute + if event.GroupVersion == kube.ApisixRouteV1 { Review comment: done -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org