allenporter / flux-local

flux-local is a set of tools and libraries for managing a local flux gitops repository focused on validation steps to help improve quality of commits, PRs, and general local testing.
https://allenporter.github.io/flux-local/
Apache License 2.0
155 stars 22 forks source link

Flux operator - GHA issue #806

Open chrede88 opened 1 day ago

chrede88 commented 1 day ago

I recently switched to use the Flux operator. Since then, the flux-local diff GHA I'm running on PR's in the repo have failed to produce an output. It looks like the steps.diff.outputs.diff is empty, but the diff action exits without errors.

I've looked through the debug logs, but I can't see anything that helps me figure out what's wrong. Maybe the current version of flux-local isn't compatible with the operator?

Here is a recent run with debug: true: https://github.com/chrede88/home-ops/actions/runs/11939162030/job/33279075345?pr=275

I'm running the latest version of flux-local: 6.0.2

allenporter commented 6 hours ago

Hi, i've never heard of the operator -- if you had to lay out the repo differently, then very likely it could not work. flux-local works by essentially traversing the GitRepository and Kustomizations. It may struggle when using an oci repo if it can't tell where it makes in the local cluster so the --sources flag could be needed. Essentially it discovers everythign through manual kustomize cfg greg and kustomize build and flux build commands. I don't really quite have enough to help but if you walked through the path for how kustomizations should be found from a raw repo in your repo i could take a look.

chrede88 commented 5 hours ago

The layout is basically the same, the main difference is that the main kustomization is now (sort of) put into the new type FluxInstance. Essentially, this was the main kustomization I had before the switch: https://github.com/chrede88/home-ops/blob/07a305ecf0f2988a38514ef6aaf987530f10384d/cluster/kubernetes/flux-system/gotk-sync.yaml This info is now put into the spec.sync in the FluxInstance: https://github.com/chrede88/home-ops/blob/07a305ecf0f2988a38514ef6aaf987530f10384d/cluster/kubernetes/flux-system/flux/flux-instance/instance.yaml#L21

I guess this cuts the kustomization path used by flux-local, which means it never discovers the rest of the repo (after the FluxInstance).

In the GHA I feed the diff the following:

- uses: allenporter/flux-local/action/diff@6.0.2
        id: diff
        with:
          live-branch: main
          path: cluster/kubernetes/flux-system
          resource: ${{ matrix.resource }}
          debug: true

Maybe it would work if I change the path to cluster/kubernetes/, as this was the path defined in the old main kustomization.

chrede88 commented 5 hours ago

Okay, I just tried by update the path to cluster/kubernetes. The two open PR's I've both failed on the helmrelease, while one ran the kustomization part with an actual output. 1/2 ran for PR 278: https://github.com/chrede88/home-ops/actions/runs/11976969764 0/2 ran for PR 277: https://github.com/chrede88/home-ops/actions/runs/11976968381