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

Problem with updating multiple charts with this same version #9

Open
luafanti opened this issue Mar 17, 2022 · 5 comments
Open

Problem with updating multiple charts with this same version #9

luafanti opened this issue Mar 17, 2022 · 5 comments

Comments

@luafanti
Copy link

I have a problem with your tool when I try to update multiple charts under /charts directory with this same version.
I have two charts:

  • nginx
  • currency-exchange

I bumped the version for both of them to 2.0.10
HCR tool updates version for one of them and return information for the second chart that version 2.0.10 already exists.

2022-03-1[7](https://github.com/luafanti/helm-chart-private2/runs/5584761897?check_suite_focus=true#step:6:7)T11:07:26.[8](https://github.com/luafanti/helm-chart-private2/runs/5584761897?check_suite_focus=true#step:6:8)5[9](https://github.com/luafanti/helm-chart-private2/runs/5584761897?check_suite_focus=true#step:6:9)335444Z	info	hcr/main.go:32	pages-branch: "gh-pages", charts-dir: "charts", pre-release: false, tag: "", remote: "origin", token: *****, dry-run: false, helm-config: sign: false, key: <empty>, keyring: <empty>, passphrase-file: <empty>
2022-03-17T11:07:26.859750165Z	info	git/client.go:120	/usr/bin/git ls-remote --heads origin
2022-03-17T11:07:27.289094528Z	info	hcr/releaser.go:173	found gh-pages github pages remote branch
2022-03-17T11:07:27.28912633Z	info	hcr/releaser.go:46	github pages remote branch exists
2022-03-17T11:07:27.289291138Z	info	helm/client.go:80	start package charts/currency-exchange chart
2022-03-17T11:07:27.292047377Z	info	helm/client.go:85	chart charts/currency-exchange packaged as currency-exchange-2.0.[10](https://github.com/luafanti/helm-chart-private2/runs/5584761897?check_suite_focus=true#step:6:10).tgz
2022-03-17T[11](https://github.com/luafanti/helm-chart-private2/runs/5584761897?check_suite_focus=true#step:6:11):07:27.2927378[12](https://github.com/luafanti/helm-chart-private2/runs/5584761897?check_suite_focus=true#step:6:12)Z	info	helm/client.go:90	chart currency-exchange loaded
2022-03-17T11:07:27.292771914Z	info	helm/client.go:80	start package charts/nginx chart
2022-03-17T11:07:27.296044979Z	info	helm/client.go:85	chart charts/nginx packaged as nginx-2.0.10.tgz
2022-03-17T11:07:27.296554105Z	info	helm/client.go:90	chart nginx loaded
2022-03-17T11:07:27.296576706Z	info	hcr/releaser.go:54	charts packaged
2022-03-17T11:07:27.29665491Z	info	git/client.go:120	/usr/bin/git remote update origin --prune
2022-03-17T11:07:27.562056801Z	info	git/client.go:120	/usr/bin/git worktree add /tmp/gh-pages492250291 origin/gh-pages
2022-03-17T11:07:27.568467524Z	info	hcr/releaser.go:153	added github pages gh-pages worktree to /tmp/gh-pages492250291
2022-03-17T11:07:27.568537028Z	info	git/client.go:120	/usr/bin/git remote get-url --push origin
2022-03-17T11:07:28.110477873Z	info	github/client.go:64	release currency-exchange-2.0.10 created
2022-03-17T11:07:28.654474521Z	warn	github/client.go:82	close currency-exchange-2.0.10.tgz asset file: close currency-exchange-2.0.10.tgz: file already closed
2022-03-17T11:07:28.654521823Z	info	github/client.go:71	asset currency-exchange-2.0.10.tgz uploaded
2022-03-17T11:07:28.655564376Z	info	helm/client.go:140	loaded /tmp/gh-pages492250291/index.yaml index file
2022-03-17T11:07:28.656926445Z	info	git/client.go:120	/usr/bin/git remote get-url --push origin
2022-03-17T11:07:28.773447624Z	info	hcr/releaser.go:115	nginx release 2.0.10 already exists, skipping
2022-03-17T11:07:28.773483026Z	info	hcr/releaser.go:72	released charts and updated index
2022-03-17T11:07:28.773540929Z	info	git/client.go:120	/usr/bin/git add index.yaml
2022-03-17T11:07:28.776506578Z	info	git/client.go:120	/usr/bin/git commit -m "update index.yaml"
2022-03-17T11:07:28.781504331Z	info	git/client.go:120	/usr/bin/git remote get-url --push origin
2022-03-17T11:07:29.417265009Z	info	hcr/releaser.go:82	index updated and pushed to github pages
2022-03-17T11:07:29.4173455[13](https://github.com/luafanti/helm-chart-private2/runs/5584761897?check_suite_focus=true#step:6:13)Z	info	git/client.go:120	/usr/bin/git worktree remove /tmp/gh-pages492250291 --force
2022-03-17T11:07:29.420231659Z	info	hcr/releaser.go:160	removed github pages gh-pages worktree /tmp/gh-pages492250291
[{"chart":"currency-exchange","tag":"2.0.10","version":"2.0.10"},{"chart":"nginx","tag":"2.0.10","version":"2.0.10"}]
2022-03-17T11:07:29.420283961Z	info	helm/client.go:71	removed generated chart currency-exchange-2.0.10.tgz
2022-03-17T11:07:29.4203[15](https://github.com/luafanti/helm-chart-private2/runs/5584761897?check_suite_focus=true#step:6:15)[36](https://github.com/luafanti/helm-chart-private2/runs/5584761897?check_suite_focus=true#step:6:36)3Z	info	helm/client.go:71	removed generated chart nginx-2.0.10.tgz

Could you help me with this problem? Maybe I missed some part of configuration?

@pete911
Copy link
Owner

pete911 commented Mar 17, 2022

Hi @luafanti, thanks for the bug report, I can see where the problem is. hcr/releaser.go:115 checks if the release exists (it does, because the previous chart created it), but does NOT check if the asset is in that release. I need to either upload assets (both charts in one step), or just check assets (not just tag on release) and edit the release (by adding assets to it).
I will try to fix it this weekend. I'll let you know when it is done.

@luafanti
Copy link
Author

I made workaround with the below snippet but will be great if you will resolve it and we are able to use your tool without any tricks :)

      - name: Package and release chart
        run: |
          git config user.email "gh-action@users.noreply.github.com"
          git config user.name "gh-action"

          for p in charts/*/
          do
            path=${p%*/}
            dir=$(basename $p)
            version=$(yq eval '.version' $path/Chart.yaml)
            echo $path $dir $version
            ./hcr -charts-dir $path -token "${{ secrets.GITHUB_TOKEN }}" -tag $dir-$version
          done

@pete911
Copy link
Owner

pete911 commented Mar 21, 2022

Hi @luafanti, v0.0.4 version should fix the issue. Let me know if everything works as it should.

@luafanti
Copy link
Author

Thx @pete911 for a quick update. I need to clarify one thing
Right now If I bump the version for two charts under /charts directory they go with a single release that contains both charts.

image

I expect to have releases per chart, but maybe my assumption is wrong and if I want to achieve it I always need to iterate over all subdirectories in /charts. Pls let me know :)

@pete911
Copy link
Owner

pete911 commented Mar 24, 2022

Hi @luafanti, the idea was to use one repo for a project/app plus its helm chart. As far as I understand the release has to be tagged. I tag it with the chart version. The problem is when you have two or more charts with the same version, I am going to check and test if the same tag can be used for different releases. Also I am not sure how it is going to work if I have lets say chart A version 0.1, chart B version 0.2, update chart A to 0.2 - tag 0.2 already exists but points to older commit.
If you have any suggestions how to make this work (we could use flags as well) let me know and I can do the changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants