source-controller
source-controller copied to clipboard
Report descriptive error for invalid chart repository URLs / index data
Hi,
I gonna use private helm chart repository that is working on GitLab CE. So i made helmrepository and helmrelease following this guideline. but as you can see, below error message printed for helmrepsitory resource that i made.
jacob@dubaek:~/workspace/flux$ kubectl get helmrepository -n ingress-nginx
NAME URL READY STATUS AGE
ingress-helm-chart https://gitlab.example.com/anyone/ingress-cache-helm False error converting YAML to JSON: yaml: line 3: mapping values are not allowed in this context 11h
I already did run flux bootstrap and there is running the source-controller (ghcr.io/fluxcd/source-controller:v0.21.2) at the cluster.
You can check the YAML file that was used to create helmrepository.
---
apiVersion: source.toolkit.fluxcd.io/v1beta1
kind: HelmRepository
metadata:
name: ingress-helm-chart
namespace: ingress-nginx
spec:
interval: 1m
url: https://gitlab.example.com/anyone/ingress-cache-helm
secretRef:
name: exampledotcom-ca
I can not find what makes syntax error or invalid line. if i applied upper YAML file without "secretRef" line, it succeed. So i think the "secretRef" has something wrong, but I could not find any problem.
Can anyone give some advice or if this issue turn out to be error, please fix it.
Hey, did you by any chance use a tab character when adding .spec.secretRef? YAML doesn't allow tabs.
Hi aryan9600,
i already check the tab character are in the yaml file. But i can not find and there is only whitespace.
below result that is run 'set list' on the VIM.
---$
apiVersion: source.toolkit.fluxcd.io/v1beta1$
kind: HelmRepository$
metadata:$
name: ingress-helm-chart$
namespace: ingress-nginx$
spec:$
interval: 1m$
url: https://gitlab.example.com/anyone/ingress-cache-helm$
secretRef:$
name: exampledotcom-ca$
$
The problem is likely that GitLab does not serve the expected index.yaml on https://gitlab.example.com/anyone/ingress-cache-helm/index.yaml, resulting in the source-controller (and Helm) attempting to consume the HTML document that is being served as YAML. Eventually resulting in this error.
You either need to figure out what the right URL is for static GitLab content (like https://raw.githubusercontent.com/<repository>/<branch>/index.yaml is for GitHub), or consume the charts in the Git repository using a GitRepository object.
As a rule of thumb for easy debugging: if helm is able to consume a URL using helm repo add <name> <url> [--username <username> --password <password], this should work with a HelmRepository object as well.
We could be nicer (like the helm CLI), and report something along the lines of:
$ helm repo add foo https://example.com
Error: looks like "https://example.com" is not a valid chart repository or cannot be reached: failed to fetch https://example.com/index.yaml : 404 Not Found
Thanks @hiddeco
I was confused, the error message was happen by parsing the YAML. i did not think about the fetching the helm chart index.html. I checked for helm chart has index.html and it's work with that helm chart Repo is working.
Also you suggest to improve the error message, right? I also agree and hope to change the message.
Thanks for your kindly support.