Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

operator-sdk failes to Initialize a new project when parent helm chart contains dependent charts #6557

Closed
r4rajat opened this issue Sep 4, 2023 · 12 comments
Labels
language/helm Issue is related to a Helm operator project triage/needs-information Indicates an issue needs more information in order to work on it. triage/support Indicates an issue that is a support question.

Comments

@r4rajat
Copy link

r4rajat commented Sep 4, 2023

Bug Report

While initializing a new project using a helm chart, which contains dependent charts: It fails.

Sample helm operator demonstrating the problem: https://github.com/r4rajat/operator-sdk-bug

What did you do?

Trying to initialize a New Project using operator-sdk init on the repository mentioned above.
The Parent Helm Chart has Dependency on Grafana, which is stored in charts folder locally.

.
└── helm/
    └── hello-world/
        ├── charts/
        │   └── grafana/
        │       ├── ci/
        │       ├── dashboards/
        │       ├── templates/
        │       ├── .helmignore
        │       ├── Chart.yaml
        │       ├── README.md
        │       └── values.yaml
        ├── templates/
        │   ├── _helpers.tpl
        │   └── deployment.yaml
        ├── .helmignore
        ├── Chart.yaml
        └── values.yaml
cat ./helm/hello-world/Chart.yaml

apiVersion: v2
name: hello-world
description: A Helm chart for Kubernetes
version: 0.1.0
appVersion: "latest"
dependencies:
  - name: grafana
    version: 6.59.0
    repository: "file://./charts/grafana"
operator-sdk init \  
--project-name=hello-world-operator --plugins=helm --domain=dev \
--helm-chart=./helm/hello-world

What did you expect to see?

Successfull execution of the command

What did you see instead? Under which circumstances?

Writing kustomize manifests for you to edit...
Creating the API:
$ operator-sdk create api --helm-chart ./helm/hello-world
Writing kustomize manifests for you to edit...

Error: failed to create API: unable to scaffold with "base.helm.sdk.operatorframework.io/v1": failed to fetch chart dependencies: directory /home/user/Projects/operator-sdk-bug/helm-charts/hello-world/charts/grafana not found
...
...
...
...
FATA[0000] failed to initialize project: unable to run post-scaffold tasks of "base.helm.sdk.operatorframework.io/v1": exit status 1 

Environment

Operator type:

/language helm

Kubernetes cluster type:

The type of cluster used for testing/deployment: OpenShift v4.12.25

$ operator-sdk version

operator-sdk version: "v1.31.0", commit: "e67da35ef4fff3e471a208904b2a142b27ae32b1", kubernetes version: "1.26.0", go version: "go1.19.11", GOOS: "linux", GOARCH: "amd64"

$ go version (if language is Go)

go version go1.20.6 linux/amd64

$ kubectl version

Client Version: v1.28.0
Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3
Server Version: v1.25.11+1485cc9
WARNING: version difference between client (1.28) and server (1.25) exceeds the supported minor version skew of +/-1

Possible Solution

Additional context

#6184

@openshift-ci openshift-ci bot added the language/helm Issue is related to a Helm operator project label Sep 4, 2023
@sukhil-suresh
Copy link

sukhil-suresh commented Sep 5, 2023

This issue was raised earlier but not resolved - #6184
Tagging others who faced the same problem (as mentioned on the other issue) - @homily707 @efiacor

@joelanford
Copy link
Member

Seems like a duplicate of #2942, which we triaged and found to be an issue with upstream helm libraries (that remains unresolved). Apparently, it's not that widespread.

Regardless there are a few workarounds proposed there. Do any of those work for you?

@varshaprasad96 varshaprasad96 added triage/needs-information Indicates an issue needs more information in order to work on it. triage/support Indicates an issue that is a support question. labels Sep 11, 2023
@varshaprasad96 varshaprasad96 modified the milestone: Backlog Sep 11, 2023
@r4rajat
Copy link
Author

r4rajat commented Sep 13, 2023

@joelanford , one of the workarounds includes using https repository instead of local sub-charts. But I have some customizations I've done in local sub-charts. If I use https repository, it over-writes my customizations

@joelanford
Copy link
Member

joelanford commented Sep 14, 2023

Can you do both of the following?

  • Commit whatever chart dependencies you have directly into the charts folder of the parent chart
  • Do not list those dependencies at all in Chart.yaml

@r4rajat
Copy link
Author

r4rajat commented Sep 14, 2023

@joelanford Yeah I've tried it. Now there is a different issue with this approach. If we remove the dependencies from parent chart, than the customizations we've made in sub-charts doesn't work.
I think it's meant to be working like this: https://github.com/helm/helm/blob/3a31588ad33fe3b89af5a2a54ee1d25bfe6eaa5e/pkg/chartutil/dependencies.go#L119C1-L121

@joelanford
Copy link
Member

the customizations we've made in sub-charts doesn't work

Can you be more specific? What kinds of customizations are being made? And what doesn't work?

@r4rajat
Copy link
Author

r4rajat commented Sep 14, 2023

@joelanford If you look at this example: https://github.com/r4rajat/operator-sdk-bug-2
we can see we don't have any dependencies in parent chart. And we have one sub chart prometheus which has 4 other child charts alertmanager, kube-state-metrics, premetheus-node-exporter and prometheus-pushgateway. Which we could enable or disable from prometheus's value.yaml, Which for now let's say is disabled.

If we remove the prometheus's dependency from our hello-world's Chart.yaml. These modifications won't work and the child charts which we have disabled, would be installed.

@joelanford
Copy link
Member

You've actually run this and tested it out? In your root CR, you should be able to set spec.alertmanager.* for the alertmanager chart's values. Not 100% positive, but I don't think templating is affected by whether the parent Chart.yaml has dependencies explicitly listed or not.

@r4rajat
Copy link
Author

r4rajat commented Sep 14, 2023

Yes, If you try helm package helm/hello-world/ and than running helm install hello-world-0.1.0.tgz --generate-name, it installs even disabled child charts

@joelanford
Copy link
Member

Perhaps the original context of this issue has run its course? It seems like leaving sub-chart directories within the parent chart's chart directory and then removing them from the Chart.yaml dependency list solves the issue described in the title of this issue.

Now it sounds like you may have a separate issue about how sub-charts are incorrectly enabled? Can we close this and start a new issue about that?

@r4rajat
Copy link
Author

r4rajat commented Sep 18, 2023

Sure @joelanford , I'll close this one and raise another issue.

@r4rajat
Copy link
Author

r4rajat commented Sep 18, 2023

@joelanford, I've created another issue: #6575

@r4rajat r4rajat closed this as completed Sep 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
language/helm Issue is related to a Helm operator project triage/needs-information Indicates an issue needs more information in order to work on it. triage/support Indicates an issue that is a support question.
Projects
None yet
Development

No branches or pull requests

4 participants