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

fix(*): Helm v3 handling of APIVersion v1 charts dependencies #7009

Merged
merged 5 commits into from
Dec 11, 2019
Merged

fix(*): Helm v3 handling of APIVersion v1 charts dependencies #7009

merged 5 commits into from
Dec 11, 2019

Conversation

TBBle
Copy link
Contributor

@TBBle TBBle commented Nov 19, 2019

This fixes unexpected changes in APIVersion1 (Helm v2) Charts when they are operated on by Helm v3 using package or dependency update.

The fixes:

  • requirements.yaml was being unconditionally merged into Chart.yaml, which produced packages which failed helm lint.
  • requirements.lock was being converted into Chart.lock by helm dep up on an APIVersion1 chart.
  • The code that loads requirements.lock and requirements.yaml in APIVersion1 charts for backwards compatibility, was incorrectly excluding those files from helm package and the Files collection in templates. As well as Files behaviour changing, this also broke sub-chart aliases for Helm v2 as those are stored in requirements.yaml.

Helm v3 incorrectly reads aliases from Chart.yaml's dependencies map in APIVersion1 charts, but I didn't change that, as helm lint warns you that this is an unexpected combination already, and it's as well as requirements.yaml so doesn't break anything.

The changes in the third commit (ae74c91) are possibly not go-idiomatic, and I specifically welcome feedback or suggested improvements.

Fixes: #6974

@helm-bot helm-bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Nov 19, 2019
@TBBle
Copy link
Contributor Author

TBBle commented Nov 20, 2019

I haven't added tests to cover the APIVersion v1 behaviours; the changes were visible in the test runs as they broke the dependency tests which were testing APIVersion v2 behaviours with a generated APIVersion v1 chart. Instead I changed those tests to test the behaviour of APIVersion v2 charts, and they pass again.

@TBBle
Copy link
Contributor Author

TBBle commented Dec 6, 2019

Is there any kind of process to go through to have a PR reviewed? This's been sitting idle for a couple of weeks now, and I'd love to know if there's more I need to do.

@hickeyma hickeyma added awaiting review bug Categorizes issue or PR as related to a bug. labels Dec 9, 2019
Copy link
Contributor

@hickeyma hickeyma left a comment

Choose a reason for hiding this comment

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

@TBBle Thank you for pushing this PR. It is a good fix. I have added some comments for consideration.
One other change is that the requirements.lock file should not be saved when packaging. The check could potentially be added before: https://github.com/helm/helm/blob/master/pkg/chartutil/save.go#L182

cmd/helm/dependency_update_test.go Show resolved Hide resolved
pkg/chartutil/chartfile.go Outdated Show resolved Hide resolved
pkg/chartutil/save.go Outdated Show resolved Hide resolved
@hickeyma hickeyma changed the title Fix APIVersion1 charts breakages when mutated with Helm v3 fix(*): Helm v3 handling of APIVersion v1 charts dependencies Dec 9, 2019
@hickeyma
Copy link
Contributor

hickeyma commented Dec 9, 2019

@TBBle Thanks for the details. Some additional feedback below.

requirements.yaml was being unconditionally merged into Chart.yaml, which produced packages which failed helm lint.

I am unable to reproduce this. Can you give more details about it?

The changes in the third commit (ae74c91) are possibly not go-idiomatic, and I specifically welcome feedback or suggested improvements.

Added feedback in #7009 (comment)

@TBBle
Copy link
Contributor Author

TBBle commented Dec 10, 2019

Why should requirements.lock be excluded from packaging of APIVersion1 charts? It was included in packages generated by Helm v2, reconfirmed with Helm v2.16.2 with the same setup as the following repro case.

@TBBle
Copy link
Contributor Author

TBBle commented Dec 10, 2019

requirements.yaml was being unconditionally merged into Chart.yaml, which produced packages which failed helm lint.

I am unable to reproduce this. Can you give more details about it?

With Helm v2.16.2:

helm create testchart

Add a requirements.yaml:

dependencies:
  - name: magic-ip-address
    version: ">0"
    repository: "@stable"

With Helm v2.16.2:

helm dependency update testchart

With Helm v3.0.0 or v3.0.1

helm package testchart
helm lint testchart-0.1.0.tgz

This will reproduce the failure:

==> Linting .\testchart-0.1.0.tgz
[INFO] Chart.yaml: icon is recommended
[ERROR] Chart.yaml: dependencies are not valid in the Chart file with apiVersion 'v1'. They are valid in apiVersion 'v2'   
Error: 1 chart(s) linted, 1 chart(s) failed

@hickeyma
Copy link
Contributor

Why should requirements.lock be excluded from packaging of APIVersion1 charts? It was included in packages generated by Helm v2, reconfirmed with Helm v2.16.2 with the same setup as the following repro case

I agree that it is included in Helm 2 but the lock file is not included in Helm 3. Is it still needed in the package as you will have the dependencies included? I would probably like to mirror Helm 3 in this regard.

@hickeyma
Copy link
Contributor

requirements.yaml was being unconditionally merged into Chart.yaml, which produced packages which failed helm lint.

Thanks for clarification of this in #7009 (comment). I missed the subtly of doing update first with Helm 2.

@TBBle
Copy link
Contributor Author

TBBle commented Dec 11, 2019

Why should requirements.lock be excluded from packaging of APIVersion1 charts? It was included in packages generated by Helm v2, reconfirmed with Helm v2.16.2 with the same setup as the following repro case

I agree that it is included in Helm 2 but the lock file is not included in Helm 3. Is it still needed in the package as you will have the dependencies included? I would probably like to mirror Helm 3 in this regard.

Personally, I'd keep it around for API stability reasons, in case someone's scripts are using .Files to extract the real subchart versions from requirements.lock or similar. It seems a reasonably-arbitrary API break for v1 to suddenly disappear the file.

Paul "Hampy" Hampson added 5 commits December 11, 2019 11:30
Fixes #6974.

This ensures that when reading a Chart marked with APIVersion v1, we
maintain the behaviour of Helm v2 and include the requirements.yaml and
requirements.lock in the Files collection, and hence produce charts that
work correctly with Helm v2.

Signed-off-by: Paul "Hampy" Hampson <p_hampson@wargaming.net>
This keeps the on-disk format consistent after `helm dependency update`
of an APIVersion1 Chart.

Signed-off-by: Paul "Hampy" Hampson <p_hampson@wargaming.net>
This fixes `helm lint` against an APIVersion1 chart packaged with Helm
v3.

Signed-off-by: Paul "Hampy" Hampson <p_hampson@wargaming.net>
As the generated chart contains no requirements.yaml in its files list,
but has dependencies in its metadata, it is not a valid APIVersion v1
chart.

Signed-off-by: Paul "Hampy" Hampson <p_hampson@wargaming.net>
Specifically for the charts that have dependencies, the generated chart
contains no requirements.yaml in its files but has dependencies in its
metadata. Hence it is not a valid APIVersion v1 chart.

Signed-off-by: Paul "Hampy" Hampson <p_hampson@wargaming.net>
Copy link
Contributor

@hickeyma hickeyma left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for the fix @TBBle

@hickeyma hickeyma merged commit 0cb0eac into helm:master Dec 11, 2019
@hickeyma hickeyma modified the milestones: 2.16.2, 3.0.2 Dec 11, 2019
@TBBle TBBle deleted the include_requirements_files_if_present branch December 13, 2019 01:38
@technosophos technosophos added the picked Indicates that a PR has been cherry-picked into the next release candidate. label Dec 17, 2019
@technosophos
Copy link
Member

picked into release-3.0

technosophos pushed a commit that referenced this pull request Dec 17, 2019
* Include requirements.* as Files in APIVersionV1

Fixes #6974.

This ensures that when reading a Chart marked with APIVersion v1, we
maintain the behaviour of Helm v2 and include the requirements.yaml and
requirements.lock in the Files collection, and hence produce charts that
work correctly with Helm v2.

Signed-off-by: Paul "Hampy" Hampson <p_hampson@wargaming.net>

* Write out requirements.lock for APIVersion1 Charts

This keeps the on-disk format consistent after `helm dependency update`
of an APIVersion1 Chart.

Signed-off-by: Paul "Hampy" Hampson <p_hampson@wargaming.net>

* Exclude 'dependencies' from APVersion1 Chart.yaml

This fixes `helm lint` against an APIVersion1 chart packaged with Helm
v3.

Signed-off-by: Paul "Hampy" Hampson <p_hampson@wargaming.net>

* Generate APIVersion v2 charts for dependency tests

As the generated chart contains no requirements.yaml in its files list,
but has dependencies in its metadata, it is not a valid APIVersion v1
chart.

Signed-off-by: Paul "Hampy" Hampson <p_hampson@wargaming.net>

* Generate APIVersion v2 charts for manager tests

Specifically for the charts that have dependencies, the generated chart
contains no requirements.yaml in its files but has dependencies in its
metadata. Hence it is not a valid APIVersion v1 chart.

Signed-off-by: Paul "Hampy" Hampson <p_hampson@wargaming.net>
@Nitive
Copy link

Nitive commented Dec 24, 2019

@TBBle @hickeyma generating requirements.lock instead of Chart.lock was a breaking change for helmfile, you can see details in roboll/helmfile#1052. Not sure if it should be fixed on a helm side

@TBBle
Copy link
Contributor Author

TBBle commented Dec 29, 2019

As noted in roboll/helmfile#1052, the change back to requirements.yaml for Helm APIVersion 1 charts was reverting an incorrect API breakage, and has now been fixed in helmfile, which was incorrectly generating APIVersion 1 (by default) charts with the APIVersion 2 Chart.lock; so were the unit tests in Helm v3 itself until this fix, so it's not surprising, just a shame this wasn't caught earlier in the Helm v3 release cycle.

bamachrn pushed a commit to bamachrn/helm that referenced this pull request Feb 28, 2020
)

* Include requirements.* as Files in APIVersionV1

Fixes helm#6974.

This ensures that when reading a Chart marked with APIVersion v1, we
maintain the behaviour of Helm v2 and include the requirements.yaml and
requirements.lock in the Files collection, and hence produce charts that
work correctly with Helm v2.

Signed-off-by: Paul "Hampy" Hampson <p_hampson@wargaming.net>

* Write out requirements.lock for APIVersion1 Charts

This keeps the on-disk format consistent after `helm dependency update`
of an APIVersion1 Chart.

Signed-off-by: Paul "Hampy" Hampson <p_hampson@wargaming.net>

* Exclude 'dependencies' from APVersion1 Chart.yaml

This fixes `helm lint` against an APIVersion1 chart packaged with Helm
v3.

Signed-off-by: Paul "Hampy" Hampson <p_hampson@wargaming.net>

* Generate APIVersion v2 charts for dependency tests

As the generated chart contains no requirements.yaml in its files list,
but has dependencies in its metadata, it is not a valid APIVersion v1
chart.

Signed-off-by: Paul "Hampy" Hampson <p_hampson@wargaming.net>

* Generate APIVersion v2 charts for manager tests

Specifically for the charts that have dependencies, the generated chart
contains no requirements.yaml in its files but has dependencies in its
metadata. Hence it is not a valid APIVersion v1 chart.

Signed-off-by: Paul "Hampy" Hampson <p_hampson@wargaming.net>
bamachrn pushed a commit to bamachrn/helm that referenced this pull request Feb 28, 2020
)

* Include requirements.* as Files in APIVersionV1

Fixes helm#6974.

This ensures that when reading a Chart marked with APIVersion v1, we
maintain the behaviour of Helm v2 and include the requirements.yaml and
requirements.lock in the Files collection, and hence produce charts that
work correctly with Helm v2.

Signed-off-by: Paul "Hampy" Hampson <p_hampson@wargaming.net>

* Write out requirements.lock for APIVersion1 Charts

This keeps the on-disk format consistent after `helm dependency update`
of an APIVersion1 Chart.

Signed-off-by: Paul "Hampy" Hampson <p_hampson@wargaming.net>

* Exclude 'dependencies' from APVersion1 Chart.yaml

This fixes `helm lint` against an APIVersion1 chart packaged with Helm
v3.

Signed-off-by: Paul "Hampy" Hampson <p_hampson@wargaming.net>

* Generate APIVersion v2 charts for dependency tests

As the generated chart contains no requirements.yaml in its files list,
but has dependencies in its metadata, it is not a valid APIVersion v1
chart.

Signed-off-by: Paul "Hampy" Hampson <p_hampson@wargaming.net>

* Generate APIVersion v2 charts for manager tests

Specifically for the charts that have dependencies, the generated chart
contains no requirements.yaml in its files but has dependencies in its
metadata. Hence it is not a valid APIVersion v1 chart.

Signed-off-by: Paul "Hampy" Hampson <p_hampson@wargaming.net>
bamachrn pushed a commit to bamachrn/helm that referenced this pull request Feb 28, 2020
)

* Include requirements.* as Files in APIVersionV1

Fixes helm#6974.

This ensures that when reading a Chart marked with APIVersion v1, we
maintain the behaviour of Helm v2 and include the requirements.yaml and
requirements.lock in the Files collection, and hence produce charts that
work correctly with Helm v2.

Signed-off-by: Paul "Hampy" Hampson <p_hampson@wargaming.net>

* Write out requirements.lock for APIVersion1 Charts

This keeps the on-disk format consistent after `helm dependency update`
of an APIVersion1 Chart.

Signed-off-by: Paul "Hampy" Hampson <p_hampson@wargaming.net>

* Exclude 'dependencies' from APVersion1 Chart.yaml

This fixes `helm lint` against an APIVersion1 chart packaged with Helm
v3.

Signed-off-by: Paul "Hampy" Hampson <p_hampson@wargaming.net>

* Generate APIVersion v2 charts for dependency tests

As the generated chart contains no requirements.yaml in its files list,
but has dependencies in its metadata, it is not a valid APIVersion v1
chart.

Signed-off-by: Paul "Hampy" Hampson <p_hampson@wargaming.net>

* Generate APIVersion v2 charts for manager tests

Specifically for the charts that have dependencies, the generated chart
contains no requirements.yaml in its files but has dependencies in its
metadata. Hence it is not a valid APIVersion v1 chart.

Signed-off-by: Paul "Hampy" Hampson <p_hampson@wargaming.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Categorizes issue or PR as related to a bug. picked Indicates that a PR has been cherry-picked into the next release candidate. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Helm v3 packaging apiVersion v1 Charts packages in apiVersion v2 format
5 participants