helm/helm

Helm dependency condition is always true when it's checking a value that doesn't exist

sincejune opened this issue · 14 comments

For each dependency in Chart.yml, the condition will be considered as true if it is checking a value that doesn't exist.

For this example:

...

dependencies:
  - name: subchart
    repository: http://localhost:10191
    version: 0.1.0
    condition: subchart.enabled

...

If subchart.enabled is missing in values.yml, the subchart will be enabled by default which is considered as an unexpected behavior.

After reading some docs and codes, it seems that it's a hacky trick that makes tags of helm dependencies work. ref: https://helm.sh/docs/topics/charts/#tags-and-condition-resolution

But that doesn't make sense if tags are absent. Do we have a plan to change the logic?

Interesting. I was able to reproduce the issue with the following:

helm create foo
helm create bar
cat << EOF >> foo/Chart.yaml
dependencies:
  - name: bar
    repository: file://../bar
    version: 0.1.0
    condition: bar.enabled
EOF
cd foo
helm dep update
helm template .
helm template . --set bar.enabled=false

Unfortunately changing the logic would be a breaking change in Helm's behavior. While I understand this was a bug, it does have the potential to break users unexpectedly "using" this behavior. Changing the way a depenency is enabled on an upgrade could result in resources being removed from their cluster, which could be catastrophic. In other words the safe option would be to hold off until Helm 4.

It's worth noting that the dependency subsystem hasn't been worked on since Helm 2 was first introduced. The core maintainer who introduced the tags system has since retired as a core maintainer. So any changes would likely need a fresh set of eyes to look at the overall dependency subsystem.

Thanks, @bacongobbler.

That makes sense. I think we can just leave it here until Helm 4 is planned.

This issue has been marked as stale because it has been open for 90 days with no activity. This thread will be automatically closed in 30 days if no further activity occurs.

Just wanted to drop in and say we have this issue in our system. We're trying to use a subchart that has dependencies, and we want one of those dependencies to be conditional based on a boolean variable. When we template from the subchart and pass the boolean as false, the dependency is successfully omitted. However, when we template from the top level chart and pass in the same value, the condition always evaluates so that the subchart conditional is true and it outputs specs we don't want.

This issue has been marked as stale because it has been open for 90 days with no activity. This thread will be automatically closed in 30 days if no further activity occurs.

ngraf commented

Still relevant for me

Relevant to me to. Even when I try to use "helm upgrade --reset-values", it doesn't delete the objects of the subchart from my release.

Relevant to us as well. This hit us in production, we missed misspelled the enabled flag and the chart was deployed despite not explictly enabling it. This is going to continue to cause issues until fixed.

actual

same in 2024