aslafy-z / helm-git

Helm Plugin - Install Helm Charts strait from Git repositories
Apache License 2.0
287 stars 46 forks source link

Bug: using `ref` with Gitlab only works without tag-message #264

Closed fuog closed 6 months ago

fuog commented 6 months ago

Hello everyone, I have a strange bug that I noticed via helmfile, but it can be isolated to just this plugin. When I try to add a repository via release-tag, I get an error. After some trial and error, I realized that I can reliably reproduce the error if the release-tag has a message and if no message is set, then the pull works without any problems. helmfile itself works with an outdated version of helm-git. however, i was able to reproduce the problem in exactly the same way with the current version. I can't really understand why a tag message makes a difference, does anyone have an idea? Helm version:
helm-git version: 0.12 - 0.15.1 Git version: gitlab v16.5.8-ee

Steps To Reproduce

  1. Create a public repo, a folder within that repo called 'charts', helm create some-chartname within that folder
  2. commit & push changes to gitlab
  3. Create a tag by UI
    • with tag message (then the pull does work)
    • without tag message (then the pull does not work)

Regarding messages: I have tried everything with the tag message, even a simple string like foobar causes the problem. Special characters can be excluded as the cause.

How did i tries to pull?

helm repo add some-reponame 'git+https://gitlab.example.com/maingroup/subgroup/subgroup2/reponame.git@charts?ref=v0.1.0'

The current behavior

in this case 0.15.1

atal: update_ref failed for ref 'HEAD': cannot update ref 'refs/heads/master': trying to write non-commit object 2335f8ef18a276dd8fc2d816dec8695fc3bd6f92 to branch 'refs/heads/master'
Error in plugin 'helm-git': Unable to sparse-checkout. Check your Git ref (v0.1.0) and path (charts).
Error: looks like "git+https://gitlab.example.com/maingroup/subgroup/subgroup2/reponame.git@charts?ref=v0.1.0" is not a valid chart repository or cannot be reached: plugin "helm-git" exited with error

The expected behavior

same behavior as when the tag hes no teg message

"some-reponame" has been added to your repositories

I'll see if the problem can also be reproduced with gitlab, the cloud service, and send you a command example that can be tested publicly.

Thank you very much for your help

fuog commented 6 months ago

yes, i can reproduce it in public with latest helm-git:

❯ helm repo add test 'git+https://gitlab.com/fuog/helm-git-debugging.git@charts?ref=with'
fatal: update_ref failed for ref 'HEAD': cannot update ref 'refs/heads/master': trying to write non-commit object cfef023dc69a952e218e0c778ee353ef5f5aef56 to branch 'refs/heads/master'
Error in plugin 'helm-git': Unable to sparse-checkout. Check your Git ref (with) and path (charts).
Error: looks like "git+https://gitlab.com/fuog/helm-git-debugging.git@charts?ref=with" is not a valid chart repository or cannot be reached: plugin "helm-git" exited with error
❯ helm repo add test 'git+https://gitlab.com/fuog/helm-git-debugging.git@charts?ref=without'
"test" has been added to your repositories

you're welcome to see the structure and tags i created within the repository.

analysing the script with set -x i see the fail ocure in the command git pull --quiet --depth 1 origin with up to that point the both execution look exactly the same. so strange ...

aslafy-z commented 6 months ago

Thank you for the report @fuog Can you please try with the sparse=0 option? Also, please define the HELM_GIT_DEBUG=1 env variable.

fuog commented 6 months ago

okay, very strange i honestly didn't expect the flag because i didn't think it would make a difference. So it works with the flag. Can you explain why exactly?

❯ HELM_GIT_DEBUG=1
❯ helm repo add test 'git+https://gitlab.com/fuog/helm-git-debugging.git@charts?ref=with'
fatal: update_ref failed for ref 'HEAD': cannot update ref 'refs/heads/master': trying to write non-commit object cfef023dc69a952e218e0c778ee353ef5f5aef56 to branch 'refs/heads/master'
Error in plugin 'helm-git': Unable to sparse-checkout. Check your Git ref (with) and path (charts).
Error: looks like "git+https://gitlab.com/fuog/helm-git-debugging.git@charts?ref=with" is not a valid chart repository or cannot be reached: plugin "helm-git" exited with error
❯ helm repo add test 'git+https://gitlab.com/fuog/helm-git-debugging.git@charts?ref=with&sparse=0'
"test" has been added to your repositories
aslafy-z commented 6 months ago

The HELM_GIT_DEBUG=1 variable should be exported:

Anyway, the issue was already reported at https://github.com/aslafy-z/helm-git/issues/9#issue-439409193

I had no time to work on the topic, however, I'd be happy to review pull requests.

Marking this issue as duplicate #9

aslafy-z commented 6 months ago

@fuog can you please try again with helm plugin install https://github.com/aslafy-z/helm-git --version 5683385eae278be4709838fdc622513f5d97d947? Thank you