Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ApplicationSet found, but no diff rendered #64

Open
juliankock opened this issue Nov 14, 2024 · 7 comments
Open

ApplicationSet found, but no diff rendered #64

juliankock opened this issue Nov 14, 2024 · 7 comments

Comments

@juliankock
Copy link

juliankock commented Nov 14, 2024

Hey!

Thanks for a wonderful initiative.

I'm having trouble rendering my ApplicationSets. It seems like they are found, but not used in diff generation, or loaded to ArgoCD. See here:

🤖 Fetching all files in dir: base-branch
🤖 Found 10 applications
🤖 Patching applications for branch: main
🤖 Patching 10 Argo CD Application[Sets] for branch: main
🤖 Fetching all files in dir: target-branch
🤖 Found 10 applications
🤖 Patching applications for branch: target-branch
🤖 Patching 10 Argo CD Application[Sets] for branch: target-branch
🚀 Creating cluster...
🚀 Cluster created successfully
🤷 No secrets found in ./secrets
🦑 Installing Argo CD Helm Chart version: 'latest'
🦑 Waiting for Argo CD to start...
🦑 Argo CD is now available
🦑 Logging in to Argo CD through CLI...
🦑 Argo CD installed successfully
🌚 Getting resources from base-branch
🌚 Got all resources from 0 applications for base
🧼 Removing applications
🧼 Removed applications successfully
🌚 Getting resources from target-branch
🌚 Got all resources from 0 applications for target
💥 Deleting cluster...
🔮 Generating diff between main and target-branch
🙏 Please check the ./output/diff.md file for differences
🎉 Done in 101 seconds

Here is an example of an ApplicationSet:

apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
  name: metadata-name
  namespace: my-namespace
spec:
  goTemplate: true
  goTemplateOptions: [ "missingkey=error" ]
  generators:
    - git:
        repoURL: [email protected]:my-repo.git
        revision: HEAD
        directories:
          - path: envs/appsets/*
  template:
    metadata:
      name: '{{.path.basename}}-prod'
      namespace: my-name-space
    spec:
      project: my-project
      sources:
        - repoURL: [email protected]:juliankock/my-repo.git
          ref: local-files
        - repoURL: [email protected]:juliankock/my-repo.git
          targetRevision: HEAD
          path: 'apps/{{.path.basename}}'
          helm:
            valueFiles:
              - '$local-files/envs/values-k8s.yaml'
      destination:
        server: https://kubernetes.default.svc
        namespace: my-namespace
      syncPolicy:
        automated:
          prune: true # Specifies if resources should be pruned during auto-syncing ( false by default ).
          selfHeal: true # Specifies if partial app sync should be executed when resources are changed only in target Kubernetes cluster and no git change detected ( false by default ).

I did look into the codebase, and I do not immediately see any overwrite of spec.template.spec.destination.namespace. May that be it?

update: tried to remove spec.template.spec.destination.namespace didn't fix it.

@dag-andersen
Copy link
Owner

Hi @juliankock,

Thank you so much!

Is your repository private?
I noticed that the tool isn't being provided with any secrets for repository access (🤷 No secrets found in ./secrets), which could prevent it from creating applications based on the git generator.

I hope this helps! If not, let me know, and we can investigate further.

@seanturner026
Copy link

seanturner026 commented Nov 20, 2024

I wonder if this only affects deploying a new directory ("Application") via an ApplicationSet? I am seeing similar behavior:

Adding a new directory doesn't cause a diff in the PR Comment:

Removing an existing directory actually caused an error:

Modifying an existing directory had the desired behavior (diff rendered):

ApplicationSet is here: https://github.com/seanturner026/argocd-applicationset/blob/8b2ad93e8c3cf920f073f4c79520d39251559d86/clusters/staging/infra-appset.yaml

And is deployed by this Application: https://github.com/seanturner026/argocd-applicationset/blob/8b2ad93e8c3cf920f073f4c79520d39251559d86/clusters/staging/argocd-app.yaml

Seems to be the case on 0.0.18 and 0.0.24? Please let me know if I should make separate Issues here. Also having a look on my end.

@dag-andersen
Copy link
Owner

Thank you for the examples and investigation, @seanturner026.
I now realize that the git-generators do not work properly! The tool is not updating the git-generator-revision-field to match the Pull request branch. I will have to fix that 🚀 Sorry for the inconvenience.

@seanturner026
Copy link

No inconvenience at all!

@dag-andersen
Copy link
Owner

dag-andersen commented Dec 22, 2024

Hi @juliankock,

This issue should now be fixed in version 0.0.26! You can check it out here: [release] 🚀
Here’s a working example: #80.

Please let me know if you’re still encountering this issue 🙏🏻 It’s possible that the behavior you’re seeing is caused by something else

@dag-andersen
Copy link
Owner

Hi @juliankock, Just wanted to follow up on this - have you had a chance to check out the new version? :) The issue you experienced might also be related to: issues 85

@juliankock
Copy link
Author

juliankock commented Jan 8, 2025

@dag-andersen

It seems like it now finds the ApplicationSets. However, since I use SSH AUTH reference to the repository, I now get the following failing GitHub action:

Error: CommandError { stderr: "time=\"2025-01-08T06:52:51Z\" level=fatal msg=\"rpc error: code = Internal desc = unable to resolve git revision : error creating SSH agent: \\\"SSH agent requested but SSH_AUTH_SOCK not-specified\\\"\"\n" }

I do mount the secrets as specified here: https://dag-andersen.github.io/argocd-diff-preview/github-actions-workflow/

So maybe I need to add an SSH key to the container?

This is only a local constraint for our running ArgoCD instance. So if possible, the library here could just change to an HTTP repoURL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants