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

[helm] reload chart for each example folder #6475

Merged

Conversation

pkoutsovasilis
Copy link
Contributor

@pkoutsovasilis pkoutsovasilis commented Jan 3, 2025

What does this PR do?

This PR fixes an issue with the Helm chart examples rendering. Specifically, the Helm chart is now reloaded for each example folder. Previously, the chart was loaded once and reused, which leads to stale data when different examples enable or disable subchart dependencies (spoiler alert for the upcoming kube-state-metrics subchart dependency PR I am working on).

Why is it important?

Reloading the Helm chart for each example folder ensures correctness in the rendered k8s manifests.

Checklist

  • I have read and understood the pull request guidelines of this project.
  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in ./changelog/fragments using the changelog tool
  • I have added an integration test or an E2E test

Disruptive User Impact

How to test this PR locally

mage helm:renderExamples

Related issues

N/A

@pkoutsovasilis pkoutsovasilis added bug Something isn't working Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team skip-changelog backport-8.x Automated backport to the 8.x branch with mergify backport-8.16 Automated backport with mergify backport-8.17 Automated backport with mergify labels Jan 3, 2025
@pkoutsovasilis pkoutsovasilis self-assigned this Jan 3, 2025
@pkoutsovasilis pkoutsovasilis requested a review from a team as a code owner January 3, 2025 05:23
@elasticmachine
Copy link
Contributor

Pinging @elastic/elastic-agent-control-plane (Team:Elastic-Agent-Control-Plane)

Copy link

Quality Gate passed Quality Gate passed

Issues
0 New issues
0 Fixed issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarQube

@swiatekm
Copy link
Contributor

swiatekm commented Jan 3, 2025

Does running init mean that we do a dependency pull on each invocation?

Previously, the chart was loaded once and reused, which leads to stale data when different examples enable or disable subchart dependencies (spoiler alert for the upcoming kube-state-metrics subchart dependency PR I am working on).

Does this also happen if the dependency is controlled via a condition in the values file?

@pkoutsovasilis
Copy link
Contributor Author

Thank you for the question @swiatekm 🙂

Does running init mean that we do a dependency pull on each invocation?

There is no dependency pull while loading the Helm chart from a path (helmChart, err := loader.Load(helmChartPath)). You must explicitly run helm dependency build ./chart_path before you can install the chart from a disk path

Does this also happen if the dependency is controlled via a condition in the values file?

My observation is that using the same helmChart from helmChart, err := loader.Load(helmChartPath) for each example sometimes resulted in the subchart not being rendered. My suspicion is that this happens because a previous example folder might have explicitly disabled that subchart by setting the condition in the values file to false, and the chart is reused without re-initializing its dependencies correctly?!.

I hope this helps clarify the behaviour I have observed, let me know if you have further questions.

Copy link
Contributor

@swiatekm swiatekm left a comment

Choose a reason for hiding this comment

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

I don't think this change has any negative side effects, but it feels like we're working around a bug in Helm.

@pkoutsovasilis pkoutsovasilis merged commit ed8e351 into elastic:main Jan 6, 2025
19 checks passed
@pkoutsovasilis pkoutsovasilis deleted the helm/magefile_fix_examples branch January 6, 2025 00:56
mergify bot pushed a commit that referenced this pull request Jan 6, 2025
mergify bot pushed a commit that referenced this pull request Jan 6, 2025
mergify bot pushed a commit that referenced this pull request Jan 6, 2025
jlind23 pushed a commit that referenced this pull request Jan 6, 2025
(cherry picked from commit ed8e351)

Co-authored-by: Panos Koutsovasilis <[email protected]>
jlind23 pushed a commit that referenced this pull request Jan 6, 2025
(cherry picked from commit ed8e351)

Co-authored-by: Panos Koutsovasilis <[email protected]>
jlind23 pushed a commit that referenced this pull request Jan 7, 2025
(cherry picked from commit ed8e351)

Co-authored-by: Panos Koutsovasilis <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-8.x Automated backport to the 8.x branch with mergify backport-8.16 Automated backport with mergify backport-8.17 Automated backport with mergify bug Something isn't working skip-changelog Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants