argoproj / argo-cd

Declarative Continuous Deployment for Kubernetes
https://argo-cd.readthedocs.io
Apache License 2.0
16.98k stars 5.17k forks source link

helm dependency build with repository alias fails with "no repository definition for @myhelmrepo" #7436

Open srouil opened 2 years ago

srouil commented 2 years ago

Describe the bug

I am creating an application whose helm Chart.yaml uses a helm library chart from a repository defined using a repository alias.

To Reproduce

  1. You need to have a helm repository containing a library chart.
  2. Configure it as helm repository in Argo CD and give it a name, e.g. myhelmrepo
  3. Configure an application from a git Repo whose Chart.yaml uses the helm library chart using an alias:

Chart.yaml

apiVersion: v2
name: dependency-test-helm
description: Helm chart
type: application
version: 1.1.0
appVersion: 0.1.0
dependencies:
- name: my-helm-library-chart
  repository: "@myhelmrepo"
  version: 0.0.1

Expected behavior

Argo CD can create the application, or if application has already been created, Argo CD displays correct sync status.

This works correctly with Argo CD 2.0.5 but I observe the error with 2.1.3

Screenshots

See Logs

Version

argocd: v2.1.3+d855831 BuildDate: 2021-09-29T21:51:21Z GitCommit: d855831540e51d8a90b1006d2eb9f49ab1b088af GitTreeState: clean GoVersion: go1.16.5 Compiler: gc Platform: linux/amd64 argocd-server: v2.1.3+d855831 BuildDate: 2021-09-29T21:51:21Z GitCommit: d855831540e51d8a90b1006d2eb9f49ab1b088af GitTreeState: clean GoVersion: go1.16.5 Compiler: gc Platform: linux/amd64 Ksonnet Version: v0.13.1 Kustomize Version: v4.2.0 2021-06-30T22:49:26Z Helm Version: v3.6.0+g7f2df64 Kubectl Version: v0.21.0 Jsonnet Version: v0.17.0

Logs

time="2021-10-14T06:54:52Z" level=info msg="manifest error cache hit: &ApplicationSource{RepoURL:https://xxx.xxx.xx/stash/scm/example-paas/example-paas-kube.git,Path:helm,TargetRevision:deploy/lab,Helm:&ApplicationSourceHelm{ValueFiles:[values-lab-fe-01.yaml],Parameters:[]HelmParameter{},ReleaseName:,Values:,FileParameters:[]HelmFileParameter{},Version:,},Kustomize:nil,Ksonnet:nil,Directory:nil,Plugin:nil,Chart:,}/952aa32f62745fc9557344d528b88d0a530cb202" 71 time="2021-10-14T06:54:52Z" level=error msg="finished unary call with code Unknown" error="Manifest generation error (cached): helm dependency build failed exit status 1: Error: no repository definition for @myhelmrepo. Please add them via 'helm repo add'" grpc.code=Unknown grpc.method=GenerateManifest grpc.request.deadline="2021-10-14T06:55:52Z" grpc.service=repository.RepoServerService grpc.start_time="2021-10-14T06:54:52Z" grpc.time_ms=2.38 span.kind=server system=grpc 70

cobexer commented 2 years ago

I hit the same error with a different config:

helm dependency build failed exit status 1: Error: could not find protocol handler for: alias

my Chart.yaml looks like:

apiVersion: v2
name: dependency-test-helm
description: Helm chart
type: application
version: 1.1.0
appVersion: 0.1.0
dependencies:
  - name: my-helm-library-chart
    repository: alias:myhelmrepo
    version: 0.0.1

this is a regression since this worked in 2.0 and below

ctron commented 2 years ago

Just ran into the same issue.

klamkma commented 2 years ago

Is there any workaround for this issue?

alekonko commented 2 years ago

hi i'm following same similar issue.

In my case I have problems using a private helm repository hosted by JFrog Artifactory, I have no problems using an instance of nexus or with a public repo (these however do not require authentication)

I have tried on different versions of argocd, from 2.0.0 to 2.1.6.

By doing several tests and I verified that the reposerver, according to the different "dependencies", once the repo is cloned locally to the pod (/ tmp / $ repourl- $ appname), executes the "helm repo add $ helm_repo_url and helm dep build) during the refresh phase.

The error reported in the logs is the following

rpc error: code = Unknown desc = Manifest generation error (cached): `helm dependency build` failed exit status 1: Error: no cached repository for helm-manager-1450a6dfaf2a71ee2466e33b0a7ed42920976b52fa1df83c16db2c2fb17e303d found. (try 'helm repo update'): open /tmp/helm230780752/cache/helm/repository/helm-manager-1450a6dfaf2a71ee2466e33b0a7ed42920976b52fa1df83c16db2c2fb17e303d-index.yaml: no such file or directory 

which may indicate that the repo has not been configured before.

I found a workaround that I am testing, that is to apply the command of "helm repo add" which, looking at the logs, is not executed in the case of JFrog Artifactory.

Bengreen commented 2 years ago

we had a similar issue and found that some of the repositories were not installed correctly (they looked green on the repository view). So we removed those and then retried and that seemed to fix the alias issue.

srouil commented 2 years ago

Hi, I could solve this problem by defining the helm repo for the dependency as source repository for the Argo CD project. It look like this change in behavior has been introduced by bug fix #6090 in Argo CD 2.1.0-rc1. Starting from 2.1.0-rc1, Controller only uses "permitted repos" instead of all helm repos when generating manifest. In my opinion, the limitation of this concept is that once a project define some helm repo as source, applications using dependencies from this helm can be deployed as well, since "helm repo add ..." is done globally in repo server.

nan-coupa commented 2 years ago

I've tried all the suggested syntax for repository and none of them work for an oci registry: repository: alias:reponame

rpc error: code = Unknown desc = helm dependency build failed exit status 1: Error: could not find protocol handler for: alias

repository: reponame

ComparisonError rpc error: code = Unknown desc = Manifest generation error (cached): helm dependency build failed exit status 1: Error: no repository definition for reponame. Please add them via 'helm repo add' Note that repositories must be URLs or aliases. For example, to refer to the "example" repository, use "https://charts.example.com/" or "@example" instead of "example". Don't forget to add the repo, too ('helm repo add').

repository: @reponame

rpc error: code = Unknown desc = Manifest generation error (cached): helm dependency build failed exit status 1: Error: no repository definition for @reponame Please add them via 'helm repo add'

@srouil where did you add the dependency and which syntax above is expected to work?

dr460neye commented 1 year ago

Upgraded to 2.6.3. Is it clear which release will contain this fix?

artarik commented 1 year ago

i have the same problems on versions 2.6.7 and 2.5.10 but it works on 2.4.14 As i can see repo-server not creating repositories.yaml andrepositories.lock in /helm-working-dir i trying manually add my helm repo but it not works

ffppmm commented 11 months ago

Hello, just updated to 2.8.0 and got the error from above:

Error: could not find protocol handler for: alias

Any idea why this happens again?

regards Philipp

ffppmm commented 10 months ago

Hello,

is there a solution for this. I also get the above error when upgrading to: https://github.com/argoproj/argo-cd/releases/tag/v2.7.14

Can somebody round up what the correct solution is, in "simple" steps, please?

We are stuck with version 2.7.7. and would really like to go to a newer version! Regards Philipp

Mazorius commented 3 months ago

Adding the repositories solved that issue for helm repositories.

Unfortunately it was not solved for OCI registries.

ffppmm commented 3 months ago

Hi,

I think helm is missing the functionality, because there is an open Pull request which solves this in the helm repo: https://github.com/helm/helm/pull/11771

I'm waiting for this to be solved to 😉, Regards Philipp

Mazorius commented 3 months ago

Using Aliases @._name”) works fine for helm repositories. But not for OCI registries. On 11. Apr 2024, at 08:35, ffppmm @.> wrote: Hi, I think helm is missing the functionality, because there is an open Pull request witch solves this in the helm repo: helm/helm#11771 Regards Philipp

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>