argo-cd icon indicating copy to clipboard operation
argo-cd copied to clipboard

Multi-source application stuck in "Unknown" status when sourceRepo is not whitelisted

Open sym-stiller opened this issue 1 year ago • 2 comments

Checklist:

  • [x] I've searched in the docs and FAQ for my answer: https://bit.ly/argocd-faq.
  • [x] I've included steps to reproduce the bug.
  • [x] I've pasted the output of argocd version.

Describe the bug

When deploying a multi-source application that is referencing a repository that was not whitelisted in the AppProject (sourceRepos setting does not include the referenced repository), the application enters an Unknown status and the underlying error is not really visible in the UI. It would be nice if the UI could provide a meaningful error message for this case, because the root cause is known. Also, when selecting the application in the UI while it is in this Unkown state, the UI crashes, displays a stacktrace, and will cease to work until I reload the page.

You can currently dig into the Application's manifest and search for such errors in its status, but that is not obvious to non-experienced users of ArgoCD/K8s.

To Reproduce

Deploy a multi-source Application that references a repository that is not whitelisted in the respective AppProject. After ArgoCD has synced, the Application will be displayed with an "Unknown" status in the UI. When you select this application in the UI, the UI will crash.

Expected behavior

ArgoCD should display a meaningful error message telling the user that the referenced repository is not whitelisted in the AppProject. The UI also shouldn't crash when selecting such a (arguably misconfigured) Application.

Version

argocd: v2.8.6+6f7af53
  BuildDate: 2023-11-01T17:06:09Z
  GitCommit: 6f7af53bea9ebc9e9eadd47fc43b671ef91c0586
  GitTreeState: clean
  GoVersion: go1.20.10
  Compiler: gc
  Platform: darwin/arm64
argocd-server: v2.8.3+77556d9

sym-stiller avatar Nov 02 '23 14:11 sym-stiller

@sym-stiller can you share a sample application for reproducing the issue? The complete UI/ CLI is still not supported for multi-source applications. But, UI crashing surely needs to be fixed.

ishitasequeira avatar Mar 05 '24 21:03 ishitasequeira

Hi @ishitasequeira ! Sure, this is a simple setup to reproduce this issue:

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: foobar-service
  namespace: argocd
  finalizers:
    - resources-finalizer.argocd.argoproj.io
spec:
  project: mycoolargocdproject
  sources:
    # Helm chart values source
    - repoURL: https://[email protected]/organizationName/projectID/_git/gitops-repo-name
      targetRevision: HEAD
      ref: helmvalues
    # Helm chart
    - chart: chart-name
      repoURL: registryname.azurecr.io
      targetRevision: 0.1.0
      helm:
        releaseName: foobar
        valueFiles:
          - $helmvalues/foobar/helm/values.yaml
  destination:
    server: https://kubernetes.default.svc
    namespace: foobar
  syncPolicy:
    automated:
      prune: true
      selfHeal: true
---
apiVersion: v1
kind: Namespace
metadata:
  name: foobar
---
apiVersion: argoproj.io/v1alpha1
kind: AppProject
metadata:
  name: mycoolargocdproject
  namespace: argocd
spec:
  description: My cool ArgoCD project
  sourceRepos:
    - 'https://[email protected]/organizationName/projectID/_git/gitops-repo-name' # Git repo (for values.yaml)
    - 'registryname.azurecr.io' # Container registry (for Helm chart OCI artifact)
  destinations:
    - namespace: '*'
      server: https://kubernetes.default.svc
  clusterResourceWhitelist:
    - group: '*'
      kind: '*'
  orphanedResources:
    warn: false

This setup should work correctly (given that the authentication for the referenced repositories/registries is correctly configured). If you remove one of the sourceRepos in the AppProject (doesn't matter which one) and try to deploy the same Application, you will run into the described issue.

sym-stiller avatar Mar 06 '24 19:03 sym-stiller

Hi @sym-stiller I tried recreating your error. I tried to remove this entry 'https://[email protected]/organizationName/projectID/_git/gitops-repo-name' from sourceRepos in AppProject through UI as we as CLI.

Removing it through UI gave me this error : Screenshot 2024-04-15 at 4 40 41 PM

Removing it through CLI gave me this error : Screenshot 2024-04-15 at 4 42 06 PM

The below thing did not happen for me, I was able to select the application multiple times, my UI was stable, did not crash & I didn't have to reload anything. Although the application DID go into an Unknown state due to the InvalidSpecError.

Also, when selecting the application in the UI while it is in this Unkown state, the UI crashes, displays a stacktrace, and will cease to work until I reload the page.

raghavi101 avatar Apr 15 '24 11:04 raghavi101

It looks like the error messages are available in at least releases 2.9 and above. Please feel free to reopen the ticket if you see the issue.

ishitasequeira avatar May 02 '24 00:05 ishitasequeira

Thanks for looking into this! 👍 I can confirm that the UI does not crash anymore, and that the error messages were greatly improved. Multi-source apps are growing more useful with each release!

sym-stiller avatar May 02 '24 09:05 sym-stiller