AlinsRan commented on code in PR #2460:
URL: 
https://github.com/apache/apisix-ingress-controller/pull/2460#discussion_r2188929996


##########
internal/provider/adc/adc.go:
##########
@@ -404,3 +415,150 @@ func prepareSyncFile(resources any) (string, func(), 
error) {
 
        return tmpFile.Name(), cleanup, nil
 }
+
+func (d *adcClient) handlerADCExecutionErrors(statusesMap 
map[string]types.ADCExecutionErrors) {
+       statusUpdateMap := d.resolveADCExecutionErrors(statusesMap)
+       d.handlerStatusUpdate(statusUpdateMap)
+}
+
+func (d *adcClient) handlerStatusUpdate(statusUpdateMap 
map[types.NamespacedNameKind][]string) {
+       for nnk, msgs := range statusUpdateMap {
+               d.updateStatus(nnk, cutils.NewConditionTypeAccepted(
+                       apiv2.ConditionReasonSyncFailed,
+                       false,
+                       0,
+                       strings.Join(msgs, "; "),
+               ))
+       }
+
+       for nnk := range d.statusUpdateMap {
+               if _, ok := statusUpdateMap[nnk]; !ok {
+                       d.updateStatus(nnk, cutils.NewConditionTypeAccepted(
+                               apiv2.ConditionReasonAccepted,
+                               true,
+                               0,
+                               "",
+                       ))
+               }
+       }
+       d.statusUpdateMap = statusUpdateMap
+}
+
+func (d *adcClient) resolveADCExecutionErrors(statusesMap 
map[string]types.ADCExecutionErrors) map[types.NamespacedNameKind][]string {
+       statusUpdateMap := map[types.NamespacedNameKind][]string{}
+       for configName, execErrors := range statusesMap {
+               log.Warnw("sync failed", zap.String("configName", configName), 
zap.Any("statuses", execErrors))
+               for _, execErr := range execErrors.Errors {
+                       for _, failedStatus := range execErr.FailedErrors {

Review Comment:
   Refactored.



##########
internal/provider/adc/adc.go:
##########
@@ -404,3 +415,150 @@ func prepareSyncFile(resources any) (string, func(), 
error) {
 
        return tmpFile.Name(), cleanup, nil
 }
+
+func (d *adcClient) handlerADCExecutionErrors(statusesMap 
map[string]types.ADCExecutionErrors) {

Review Comment:
   fixed.



##########
internal/provider/adc/store.go:
##########
@@ -244,3 +245,79 @@ func (s *Store) GetResources(name string) 
(*adctypes.Resources, error) {
                PluginMetadata: metadata,
        }, nil
 }
+
+func (s *Store) ListGlobalRules(name string) ([]*adctypes.GlobalRuleItem, 
error) {
+       s.Lock()
+       defer s.Unlock()
+       targetCache, ok := s.cacheMap[name]
+       if !ok {
+               return nil, fmt.Errorf("cache not found for name: %s", name)
+       }
+       globalRules, err := targetCache.ListGlobalRules()
+       if err != nil {
+               return nil, fmt.Errorf("failed to list global rules: %w", err)
+       }
+       return globalRules, nil
+}
+
+func (s *Store) GetResourceLabel(name, resourceType string, id string) 
(map[string]string, error) {
+       s.Lock()
+       defer s.Unlock()
+       targetCache, ok := s.cacheMap[name]
+       if !ok {
+               return nil, fmt.Errorf("cache not found for name: %s", name)
+       }
+       switch resourceType {
+       case "service":

Review Comment:
   fixed.



-- 
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.

To unsubscribe, e-mail: notifications-unsubscr...@apisix.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to