8000 Deprecate cr index "charts-repo" flag. Instead read index.yaml from git repository by torstenwalter · Pull Request #144 · helm/chart-releaser · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Deprecate cr index "charts-repo" flag. Instead read index.yaml from git repository #144

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& 10000 rdquo;, 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

Merged
merged 5 commits into from
Nov 15, 2021

Conversation

torstenwalter
Copy link
Contributor

So far the index.yaml was loaded directly from the chart repository. In case of GitHub pages that's https://.github.io/
The problem with this approach is that GitHub pages use a Content Delivery Network. So the index.yaml files fetched from there might be outdated as there is a delay between a git push to the gh-pages branch until the content is visible.
This delay might lead to the situation that one downloads an old index file from and updated that one instead of the most recent index.yaml.

For the grafana repository that resulted in already released charts being removed again.

This PR resolves that issue by reading the index.yaml from the gh_pages branch of the repository. The branch needs to be up-to-date anyhow if you want to create a PR or directly push the changes.

It should also be fine for the chart-releaser-action as it uses a fetch-depth: 0 to clone the whole repository.

jobs:
  release:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2
        with:
          fetch-depth: 0

Fixes: #143

So far the index.yaml was loaded directly from the chart repository.
In case of GitHub pages that's https://<user or org>.github.io/<repo>

The problem with this approach is that GitHub pages use a Content
Delivery Network. So the index.yaml files fetched from there might be
outdated as there is a delay between a git push to the gh-pages branch
until the content is visible.

This delay might lead to the situation that one downloads an old index
file from and updated that one instead of the most recent index.yaml.

For the grafana repository that resulted in already released charts
being removed again.
- grafana/helm-charts#783
- grafana/helm-charts#796

This PR resolves that issue by reading the index.yaml from the gh_pages
branch of the repository. The branch needs to be up-to-date anyhow if
you want to create a PR or directly push the changes.

It should also be fine for the chart-releaser-action as it uses
a fetch-depth: 0 to clone the whole repository.

```
jobs:
  release:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2
        with:
          fetch-depth: 0
```

Fixes: helm#143

Signed-off-by: Torsten Walter <torsten.walter@syncier.com>
Signed-off-by: Torsten Walter <torsten.walter@syncier.com>
Copy link
Member
@scottrigby scottrigby left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@torstenwalter good idea, and thank you! Nice implementation 👏

In order for us to include this in a PATCH release, we should not remove the charts-repo flag in this PR. Instead, we can deprecate it:

  • mark as deprecated in the code
  • hide the command flag from help output
  • when the flag is used, add a CLI message to note this is now deprecated: quick explanation why it's is no longer necessary (index now drawn directly from the configurable gh pages branch to bypass gh periodic CDN delay etc), and let folks know it will be removed in the next MAJOR release
  • regenerate/update usage text in README with the now hidden command

Removing the flag now will break existing CI that uses helm/chart-releaser directly. We can coordinate updating the helm/chart-releaser-action version to handle this properly when we bump the chart-releaser version used there, but that won't help users who rely on this project directly rather than using the gh action to wrap it.

@scottrigby scottrigby changed the title read index.yaml from git repository Deprecate cr index "charts-repo" flag. Instead read index.yaml from git repository Nov 11, 2021
@scottrigby
Copy link
Member

@torstenwalter I also updated this PR title so the flag deprecation will show up clearly in the changelog

@torstenwalter
Copy link
Contributor Author
torstenwalter commented Nov 11, 2021

@scottrigby and I was hoping to get rid of the compatibility as it makes the code way more complicated ;-)
What would be your prosal how to handle it in code if charts-repo flag is provided stick to the old implementation in case it's not provided read the index.yaml from the git repository?

@scottrigby
Copy link
Member

@torstenwalter I think you're right we don't need to fall back to old logic. If we mark the flag as deprecated and clarify it no longer does anything (now handled using a 100% backwards compatible technique of grabbing index from the branch rather than over CDN), we are still backwards compatible and can PATCH release.

In 2.x we can make MAJOR changes like removing flags and other not 100% backwards-compatible changes.

The alternative is to bump to 2.x now. I just think this one change can be made in a backwards-compatible way pretty easily. Do you agree?

@scottrigby
Copy link
Member
scottrigby commented Nov 11, 2021

A context note: hip-0004 focuses on helm/helm, but the spirit is for the Helm project as a whole. Backwards compatibility may have been less rigorous from time to time for helm sub-projects, but to the best of our ability, we should keep the trust in helm subprojects (like helm/chart-releaser) by being as strict and transparent as we can about following semver's backwards compatibility rules for these sub-projects too 🙂

- message is printed when using the flag to let users know that it's
  deprecated
- update all docs in README

Signed-off-by: Torsten Walter <torsten.walter@syncier.com>
@torstenwalter
Copy link
Contributor Author

Updated as requested. I also upated other outdated documentation in the README.

cr/cmd/index.go Outdated
Comment on lines 41 to 47
if len(config.ChartsRepo) > 0 {
fmt.Fprintf(os.Stderr, "ATTENTION: Flag --charts-repo is deprecated. It does not have any effect.\n"+
"The index.yaml is read from the '%s' branch instead.\n"+
"Loading index.yaml directly from the charts repository lead to problems as there is a delay between\n"+
"pushing to the github pages branch until things apear online.\n"+
"The flag will be removed with the next major release.", config.PagesBranch)
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I decided to print the deprecation message here. Alternative would have been the releaser.UpdateIndexFile() method.

Co-authored-by: Reinhard Nägele <unguiculus@gmail.com>
Signed-off-by: Torsten Walter <mail@torstenwalter.de>
Signed-off-by: Torsten Walter <torsten.walter@syncier.com>
Copy link
Member
@unguiculus unguiculus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member
@scottrigby scottrigby left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏 lgtm!

@scottrigby scottrigby merged commit a5166bb into helm:main Nov 15, 2021
@torstenwa
8000
lter
Copy link
Contributor Author

@scottrigby @unguiculus is it possible to create a new release with this change?

@cpanato
Copy link
Member
cpanato commented Feb 24, 2022

i will review and see what more things we have and prepare a release

@scottrigby
Copy link
Member

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

Successfully merging this pull request may close these issues.

Index reverted when multiple runs happen in parallel
5 participants
0