rancher / fleet

Deploy workloads from Git to large fleets of Kubernetes clusters
https://fleet.rancher.io/
Apache License 2.0
1.48k stars 217 forks source link

Helm valuesFiles is being ignored in certain cases #2060

Open abrekken opened 6 months ago

abrekken commented 6 months ago

Is there an existing issue for this?

Current Behavior

Hi all, I'm new to Fleet so I'll start this with the usual: "not sure if this is a bug or by design" disclaimer. I've got a GitRepo defined with multiple paths, each of which points to a directory in the repo that contains a Chart.yaml and the usual helm artifacts. (templates folder, values.yaml, and values subfolder with specific values files within it) I also created a fleet.yaml file in each of the chart directories which is mostly empty except for a valuesFiles block like this:

helm:
  chart: ""
  repo: ""
  release: "1.0.0"
  force: false
  timeoutSeconds: 0
  valuesFiles:
    - values/values-1.yaml

The problem is my values file (values-1.yaml in the values folder) is not getting picked up. I looked through the code and it looks like there are 2 places where the valuesFiles gets read. Here: https://github.com/rancher/fleet/blob/master/internal/bundlereader/resources.go#L41 and here: https://github.com/rancher/fleet/blob/master/internal/bundlereader/resources.go#L48

In my case, I'm using fleet local (single cluster), so I don't have any targets defined so that explains why it's not getting read there at line 48. But the earlier call at line 41 requires a non-empty string chart to be defined. If I change that to just a dot like this: chart: "." then everything works. By I don't understand why this check in the code exists... Because my GitRepo already has a path defined to the directory where the Chart.yaml lives, I shouldn't need to specify this right - my fleet.yaml is already in this path.

It's an easy workaround to "fix" this, but it feels like I shouldn't need to and it's definitely not documented from what I can tell. That said, I'm new to Fleet so maybe there's a reason for this behavior. At a minimum though, it seems like something that should be documented. I spent more time than I care to admit stuck on this until I finally decided to look through the code. :). Thanks!

Expected Behavior

No response

Steps To Reproduce

Create a bundle with chart:"" left as an empty string and specify a values file using the helm.valuesFiles object. Notice that the values file you specified is not used in templating.

Environment

- Architecture:x64
- Fleet Version: 01.0.0+up0.5.0

Logs

No response

Anything else?

No response

solarvm commented 4 months ago

Thanks @abrekken , you've saved me quite a bit of time peeking into sources. I have just hit the same. Confirming both the issue and the workaround.