helmfile: jsonPatches failed with missing dependencies of a chart
When running helmfile sync with following Yaml
repositories:
- name: bitnami
url: https://charts.bitnami.com/bitnami
caFile: bitnami.pem
helmDefaults:
args:
- "--debug"
atomic: true
cleanupOnFail: true
skipDeps: false
releases:
- name: cassandra-bit
namespace: cassandra
labels:
team: noops
chart: bitnami/cassandra
values:
- values-cassandra.yaml
jsonPatches:
- target:
version: apps/v1
kind: StatefulSet
name: cassandra-bit
patch:
- op: add
path: /spec/template/metadata/annotations
value:
deonPatchesloyment/timestamp: "{{ now | unixEpoch }}"
helmfile exited with error it cant find the only dependency of the chart.
Adding repo bitnami https://charts.bitnami.com/bitnami
"bitnami" has been added to your repositories
running helm fetch bitnami/cassandra --untar -d /tmp/chartify775686341
using requirements.yaml:
{}
options: {false [/tmp/values195671422] [] cassandra true}
running helm template --debug=false --include-crds --output-dir /tmp/chartify775686341/cassandra/helmx.1.rendered -f /tmp/chartify775686341/cassandra/values.yaml -f /tmp/values195671422 --namespace cassandra cassandra-bit /tmp/chartify775686341/cassandra
patching files: [/tmp/chartify775686341/cassandra/templates/networkpolicy.yaml /tmp/chartify775686341/cassandra/templates/cassandra-secret.yaml /tmp/chartify775686341/cassandra/templates/headless-svc.yaml /tmp/chartify775686341/cassandra/templates/service.yaml /tmp/chartify775686341/cassandra/templates/statefulset.yaml]
jsonpatches/patch.0.yaml:
- op: add
path: /spec/template/metadata/annotations
value:
deonPatchesloyment/timestamp: "1611071318"
generated and using kustomization.yaml:
kind: ""
apiversion: ""
resources:
- templates/networkpolicy.yaml
- templates/cassandra-secret.yaml
- templates/headless-svc.yaml
- templates/service.yaml
- templates/statefulset.yaml
patchesJson6902:
- target:
kind: StatefulSet
name: cassandra-bit
version: apps/v1
path: jsonpatches/patch.0.yaml
Generating /tmp/chartify775686341/cassandra/all.patched.yaml
running kustomize build /tmp/chartify775686341/cassandra --output /tmp/chartify775686341/cassandra/all.patched.yaml
Removing /tmp/chartify775686341/cassandra/templates
Removing /tmp/chartify775686341/cassandra/charts
Removing /tmp/chartify775686341/cassandra/crds
Removing /tmp/chartify775686341/cassandra/strategicmergepatches
Removing /tmp/chartify775686341/cassandra/kustomization.yaml
Affected releases are:
cassandra-bit (/tmp/chartify775686341/cassandra) UPDATED
Upgrading release=cassandra-bit, chart=/tmp/chartify775686341/cassandra
Release "cassandra-bit" does not exist. Installing it now.
FAILED RELEASES:
NAME
cassandra-bit
in ./helmfile.yaml: failed processing release cassandra-bit: command "/home/opdt/.local/bin/helm" exited with non-zero status:
PATH:
/home/opdt/.local/bin/helm
ARGS:
0: helm (4 bytes)
1: upgrade (7 bytes)
2: --install (9 bytes)
3: --reset-values (14 bytes)
4: cassandra-bit (13 bytes)
5: /tmp/chartify775686341/cassandra (32 bytes)
6: --atomic (8 bytes)
7: --cleanup-on-fail (17 bytes)
8: --create-namespace (18 bytes)
9: --namespace (11 bytes)
10: cassandra (9 bytes)
11: --values (8 bytes)
12: /tmp/values755635552 (20 bytes)
13: --history-max (13 bytes)
14: 10 (2 bytes)
15: --debug (7 bytes)
ERROR:
exit status 1
EXIT STATUS
1
STDERR:
history.go:53: [debug] getting history for release cassandra-bit
install.go:172: [debug] Original chart version: ""
install.go:189: [debug] CHART PATH: /tmp/chartify775686341/cassandra
Error: found in Chart.yaml, but missing in charts/ directory: common
helm.go:81: [debug] found in Chart.yaml, but missing in charts/ directory: common
helm.sh/helm/v3/pkg/action.CheckDependencies
/home/circleci/helm.sh/helm/pkg/action/install.go:606
main.runInstall
/home/circleci/helm.sh/helm/cmd/helm/install.go:215
main.newUpgradeCmd.func2
/home/circleci/helm.sh/helm/cmd/helm/upgrade.go:114
github.com/spf13/cobra.(*Command).execute
/go/pkg/mod/github.com/spf13/cobra@v1.0.0/command.go:842
github.com/spf13/cobra.(*Command).ExecuteC
/go/pkg/mod/github.com/spf13/cobra@v1.0.0/command.go:950
github.com/spf13/cobra.(*Command).Execute
/go/pkg/mod/github.com/spf13/cobra@v1.0.0/command.go:887
main.main
/home/circleci/helm.sh/helm/cmd/helm/helm.go:80
runtime.main
/usr/local/go/src/runtime/proc.go:203
runtime.goexit
/usr/local/go/src/runtime/asm_amd64.s:1373
COMBINED OUTPUT:
history.go:53: [debug] getting history for release cassandra-bit
Release "cassandra-bit" does not exist. Installing it now.
install.go:172: [debug] Original chart version: ""
install.go:189: [debug] CHART PATH: /tmp/chartify775686341/cassandra
Error: found in Chart.yaml, but missing in charts/ directory: common
helm.go:81: [debug] found in Chart.yaml, but missing in charts/ directory: common
helm.sh/helm/v3/pkg/action.CheckDependencies
/home/circleci/helm.sh/helm/pkg/action/install.go:606
main.runInstall
/home/circleci/helm.sh/helm/cmd/helm/install.go:215
main.newUpgradeCmd.func2
/home/circleci/helm.sh/helm/cmd/helm/upgrade.go:114
github.com/spf13/cobra.(*Command).execute
/go/pkg/mod/github.com/spf13/cobra@v1.0.0/command.go:842
github.com/spf13/cobra.(*Command).ExecuteC
/go/pkg/mod/github.com/spf13/cobra@v1.0.0/command.go:950
github.com/spf13/cobra.(*Command).Execute
/go/pkg/mod/github.com/spf13/cobra@v1.0.0/command.go:887
main.main
/home/circleci/helm.sh/helm/cmd/helm/helm.go:80
runtime.main
/usr/local/go/src/runtime/proc.go:203
runtime.goexit
/usr/local/go/src/runtime/asm_amd64.s:1373
if i remove the block
jsonPatches:
- target:
version: apps/v1
kind: StatefulSet
name: cassandra-bit
patch:
- op: add
path: /spec/template/metadata/annotations
value:
deonPatchesloyment/timestamp: "{{ now | unixEpoch }}"
everything works fine … except the Patch, of course.
# kustomize version
{Version:kustomize/v3.9.2 GitCommit:e98eada7365fc564c9aba392e954f306a9cbf1dd BuildDate:2021-01-17T17:44:16Z GoOs:linux GoArch:amd64}
# helm version
version.BuildInfo{Version:"v3.4.2", GitCommit:"23dd3af5e19a02d4f4baa5b2f242645a1a3af629", GitTreeState:"clean", GoVersion:"go1.14.13"}
# helmfile version
helmfile version v0.135.0
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 1
- Comments: 20 (2 by maintainers)
Commits related to this issue
- Fix chartify not to fail on a chart with dependencies Ref https://github.com/roboll/helmfile/issues/1655#issuecomment-809291923 — committed to helmfile/chartify by mumoshu 3 years ago
- Fix chartify not to fail on a chart with dependencies Fixes #1655 — committed to roboll/helmfile by mumoshu 3 years ago
- Fix chartify not to fail on a chart with dependencies (#1759) Manually verified to work by using the following example from @damoon (https://github.com/roboll/helmfile/issues/1655#issuecomment-801122... — committed to roboll/helmfile by mumoshu 3 years ago
Please see https://github.com/variantdev/chartify/commit/07c3054d66021fa190464a998ade18607312c715 and #1759 for the fix. Thanks again for sharing your insight @strainovic! It helped a lot!
I implemented a quick test/fix using yq within the Chartify function to remove the dependencies from Charts.yaml.
It solves the issue in this case.
But it uncovered a new issue: when using patches CRDs are always included. Flags to exclude the CRDs in helmfile or helm do not have any effect.
The problem seems that once you’ve defined a
jsonPatches, helmfile builds up a temporary chart usingchartifyand after applying the layers withkustomizationand ready to deploy, it doesn’t fetch the remotebitnami/commonHelm chart, defined in the upstream Helm chart as a dependency.I’ve a similar issue as I’d like to use
incubator/rawas a dependency for workaround the lack of creating brand new k8s objects (e.g.ServiceMonitor) without define a separate release.