Giter Site home page Giter Site logo

Comments (13)

travisghansen avatar travisghansen commented on August 16, 2024 1

Yes! Thanks for pointing this out and great find! I'll get it cleaned up with something more appropriate.

from argo-cd-helmfile.

travisghansen avatar travisghansen commented on August 16, 2024

Welcome! argocd plugins execute in 2 phases, an init phase and a generate phase. The repo side of it should be dealt with here: https://github.com/travisghansen/argo-cd-helmfile/blob/master/src/argo-cd-helmfile.sh#L353

from argo-cd-helmfile.

iverberk avatar iverberk commented on August 16, 2024

Thanks for the quick response.

Ah ok, so that clarifies where the repositories are supposed to be added. I'm only getting an error related to the generate command. ArgoCD doesn't seem to run the init command. I've on purpose modified my helmfile.yaml to produce an error when being processed by helmfile. I would expect ArgoCD to throw me an error that the init command failed because helmfile can't parse the helmfile.yaml file. Instead, I only again see the generate command.

Do you have any ideas why the init command might not be called or how to go about debugging?

from argo-cd-helmfile.

iverberk avatar iverberk commented on August 16, 2024

I've added a custom (non-existent) init script via the environment variable. It does fail with a message telling me that the script does not exist, so that leads me to conclude that init is being called. But why the helmfile repos command is not executed is still unclear to me.

from argo-cd-helmfile.

travisghansen avatar travisghansen commented on August 16, 2024

If any command in the plugin fails the script will exit. So the behavior actually makes sense because the custom init script is executed just before the helmfile repos command.

from argo-cd-helmfile.

travisghansen avatar travisghansen commented on August 16, 2024

Can you send over the application yaml and the version of the plugin currently in use? The only thing I can think of at the moment is there some logic error with the caching logic.

from argo-cd-helmfile.

iverberk avatar iverberk commented on August 16, 2024

Yeah I was also zooming in on the caching logic but couldn't find a good way to debug.

This is the application YAML (redacted):

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: abc
spec:
  destination:
    namespace: ns
    server: https://kubernetes.default.svc
  project: default
  source:
    path: apps/abc
    plugin:
      env:
      - name: HELMFILE_TEMPLATE_OPTIONS
        value: --environment env-abc --include-crds
    repoURL: https://gitlab/aaa/bbb.git
    targetRevision: main
  syncPolicy:
    automated: {}
    syncOptions:
    - CreateNamespace=true
    - ServerSideApply=false

and the helmfile:

bases:
  - ../../../../env-dev.yaml
  - ../../../../env.yaml
---
repositories:
  - name: repo-abc
    url: https://aaa.bbb.ccc

releases:
  - name: dex
    namespace: dex
    chart: repo-abc/dex
    version: 0.14.1
    missingFileHandler: Warn
    values:
      - ./values.yaml
      {{- if .Values.dev  }}

      - ./overrides/dev/values.yaml
      - ./overrides/dev/{{ .Environment.Name }}/values.yaml

      {{- else }}

      - ./overrides/{{ .Environment.Name }}/values.yaml.gotmpl

      {{- end }}

  - name: manifests
    namespace: dex
    chart: ./manifests

Plugin version: travisghansen/argo-cd-helmfile:latest (unfortunately not pinned to a specific version). Is there any way to get more debug logging? To double check that the helmfile repos command is actually executed.

from argo-cd-helmfile.

travisghansen avatar travisghansen commented on August 16, 2024

Set DEBUG=1 env var for the sidecar or in the app and it will spew a bunch out but it can be hard to find.

from argo-cd-helmfile.

iverberk avatar iverberk commented on August 16, 2024

As an intermediate finding I wanted to mention that creating a custom init script that calls the helmfile repos command actually solves the issue. This leads me to conclude that the helmfile repos command is not executed under normal circumstances. Just to validate: do you define repositories in the helmfile and do they work for you? This seems like the most basic of features so I would be surprised if it didn't work at all. I'll continue the investigation.

from argo-cd-helmfile.

travisghansen avatar travisghansen commented on August 16, 2024

I do define the repos in my set of helmfiles. Something is clearly strange in your scenario. Maybe you can exec into the plugin container and try to execute the command directly and debug that way?

from argo-cd-helmfile.

iverberk avatar iverberk commented on August 16, 2024

Ok, I figured out why it was failing. My helmfile commands require an environment to be passed as argument otherwise it will fail. I added the HELMFILE_TEMPLATE_OPTIONS environment variable with the required environment setting. I didn't realise until now that I needed to set the HELMFILE_GLOBAL_OPTIONS environment variable so that the helmfile repos command also uses this argument. I never needed it before because the Helm charts were local to the repo.

I think what happens is, that the helmfile repos command silently fails without causing the script to error. Without an error you don't see any output and Argo CD will happily proceed to the generate stage. This construction might be a little bit too clever: https://github.com/travisghansen/argo-cd-helmfile/blob/master/src/argo-cd-helmfile.sh#L351

Shellcheck gives some information that might be useful: https://www.shellcheck.net/wiki/SC2015

Bash....so many subtle ways it might fail :-)

I'll leave it to you if you want me to close this issue or that you want to try out my theory regarding the silent failure and potentially fix it with a straight-up if-then-else construct.

from argo-cd-helmfile.

iverberk avatar iverberk commented on August 16, 2024

This little snippet clarifies things:

#!/bin/bash

set -e

true && {
  helmfile repos --tst
} || {
  echo "yo"
}

It will both produce an error because the --tst argument is not recognized and echo "yo". It will then exit with a zero exit code, indicating all went well which is obviously not what you want.

from argo-cd-helmfile.

travisghansen avatar travisghansen commented on August 16, 2024

Fix here: 6299491

Wait for v0.3.6 to build and then give it a try and let me know if it's fixed.

from argo-cd-helmfile.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.