| 2407 | } |
| 2408 | |
| 2409 | func (ctrl *ApplicationController) canProcessApp(obj any) bool { |
| 2410 | app, ok := obj.(*appv1.Application) |
| 2411 | if !ok { |
| 2412 | return false |
| 2413 | } |
| 2414 | |
| 2415 | // Only process given app if it exists in a watched namespace, or in the |
| 2416 | // control plane's namespace. |
| 2417 | if !ctrl.isAppNamespaceAllowed(app) { |
| 2418 | return false |
| 2419 | } |
| 2420 | |
| 2421 | if annotations := app.GetAnnotations(); annotations != nil { |
| 2422 | if skipVal, ok := annotations[common.AnnotationKeyAppSkipReconcile]; ok { |
| 2423 | logCtx := log.WithFields(applog.GetAppLogFields(app)) |
| 2424 | if skipReconcile, err := strconv.ParseBool(skipVal); err == nil { |
| 2425 | if skipReconcile { |
| 2426 | logCtx.Debugf("Skipping Application reconcile based on annotation %s", common.AnnotationKeyAppSkipReconcile) |
| 2427 | return false |
| 2428 | } |
| 2429 | } else { |
| 2430 | logCtx.WithError(err).Debugf("Unable to determine if Application should skip reconcile based on annotation %s", common.AnnotationKeyAppSkipReconcile) |
| 2431 | } |
| 2432 | } |
| 2433 | } |
| 2434 | |
| 2435 | destCluster, err := argo.GetDestinationCluster(context.Background(), app.Spec.Destination, ctrl.db) |
| 2436 | if err != nil { |
| 2437 | return ctrl.clusterSharding.IsManagedCluster(nil) |
| 2438 | } |
| 2439 | return ctrl.clusterSharding.IsManagedCluster(destCluster) |
| 2440 | } |
| 2441 | |
| 2442 | func (ctrl *ApplicationController) newApplicationInformerAndLister() (cache.SharedIndexInformer, applisters.ApplicationLister) { |
| 2443 | watchNamespace := ctrl.namespace |