Skip to content

✨ Add support for deploying OCI helm charts in OLM v1 #1971

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

OchiengEd
Copy link
Contributor

@OchiengEd OchiengEd commented May 15, 2025

  • added support for deploying OCI helm charts which sits behind the HelmChartSupport feature gate
  • extend the Cache Store() method to allow storing of Helm charts alongside OCI images
  • inspect chart archive contents for chart contents

Description

This pull request aims to add logic to OLM v1 for handling OCI Helm chart support. We expect more work to go into this feature as further discussion on this occurs on issue #962 and the Arbitrary Configuration RFC which may inform how values.yml would be passed to Helm charts.

Reviewer Checklist

  • API Go Documentation
  • Tests: Unit Tests (and E2E Tests, if appropriate)
  • Comprehensive Commit Messages
  • Links to related GitHub Issue(s)

@OchiengEd OchiengEd requested a review from a team as a code owner May 15, 2025 17:23
Copy link

netlify bot commented May 15, 2025

Deploy Preview for olmv1 ready!

Name Link
🔨 Latest commit 46af89e
🔍 Latest deploy log https://app.netlify.com/projects/olmv1/deploys/685c342e51553b0008007857
😎 Deploy Preview https://deploy-preview-1971--olmv1.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@openshift-ci openshift-ci bot requested review from camilamacedo86 and trgeiger May 15, 2025 17:23
Copy link

openshift-ci bot commented May 15, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign thetechnick for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Copy link

codecov bot commented May 15, 2025

Codecov Report

Attention: Patch coverage is 75.00000% with 42 lines in your changes missing coverage. Please review.

Project coverage is 73.83%. Comparing base (00b965c) to head (46af89e).

Files with missing lines Patch % Lines
internal/shared/util/image/cache.go 70.58% 10 Missing and 5 partials ⚠️
internal/shared/util/image/helm.go 86.40% 9 Missing and 5 partials ⚠️
internal/operator-controller/applier/helm.go 0.00% 8 Missing and 1 partial ⚠️
internal/shared/util/image/pull.go 20.00% 3 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1971      +/-   ##
==========================================
+ Coverage   73.82%   73.83%   +0.01%     
==========================================
  Files          81       82       +1     
  Lines        7365     7530     +165     
==========================================
+ Hits         5437     5560     +123     
- Misses       1588     1618      +30     
- Partials      340      352      +12     
Flag Coverage Δ
e2e 43.12% <3.57%> (-0.94%) ⬇️
unit 60.57% <75.00%> (+0.32%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@OchiengEd OchiengEd force-pushed the helm_explorations branch from 3b36dfb to 272dcbf Compare May 15, 2025 17:40
@OchiengEd OchiengEd force-pushed the helm_explorations branch from 272dcbf to 39948a0 Compare May 21, 2025 15:51
Copy link
Contributor

@camilamacedo86 camilamacedo86 left a comment

Choose a reason for hiding this comment

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

OH. Great work 🥇

@OchiengEd OchiengEd force-pushed the helm_explorations branch 4 times, most recently from 6dfc6c0 to 059008d Compare June 3, 2025 18:04
@OchiengEd
Copy link
Contributor Author

When pulling a Helm chart with a provenance file, at this time we have chosen to skip pulling the layer to the cache filesystem since we have no logic in place at this time to verify the chart integrity.

// Ignore the Helm provenance data layer
if layer.MediaType == registry.ProvLayerMediaType {
continue
}

@camilamacedo86 camilamacedo86 self-requested a review June 11, 2025 16:01
@OchiengEd OchiengEd force-pushed the helm_explorations branch from b569fb8 to 9f59039 Compare June 11, 2025 19:59
@OchiengEd OchiengEd force-pushed the helm_explorations branch from 9f59039 to c08ce64 Compare June 12, 2025 16:27
ociImg, err := img.OCIConfig(ctx)
if err != nil {
return nil, time.Time{}, err
}

layerIter := iter.Seq[LayerData](func(yield func(LayerData) bool) {
for i, layerInfo := range img.LayerInfos() {
ld := LayerData{Index: i}
ld := LayerData{Index: i, MediaType: layerInfo.MediaType}
Copy link
Contributor

Choose a reason for hiding this comment

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

It is added with the helm chart, but I think it is OK to exist on the default code as well.
@tmshort @thetechnick WDYT?

@OchiengEd OchiengEd force-pushed the helm_explorations branch from c08ce64 to 9b366d3 Compare June 12, 2025 18:04
Comment on lines 134 to 147
switch layer.MediaType {
case registry.ChartLayerMediaType:
if err := storeChartLayer(dest, layer); err != nil {
return err
}
default:
if _, err := archive.Apply(ctx, dest, layer.Reader, applyOpts...); err != nil {
return fmt.Errorf("error applying layer[%d]: %w", layer.Index, err)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Should it not be protected behind the feature flag as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The code will be unreachable as a result of the pullChart() function being wrapped around a feature gate. However, if we need to wrap that code as well, feel tree to let me know

if features.OperatorControllerFeatureGate.Enabled(features.HelmChartSupport) {
if hasChart(img) {
return pullChart(ctx, ownerID, srcRef, canonicalRef, imgSrc, cache)
}
}

Copy link
Contributor

@camilamacedo86 camilamacedo86 Jun 12, 2025

Choose a reason for hiding this comment

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

I believe that all code should be categorised under a flag, allowing us to easily identify the purpose of each specific code for each alpha/beta feature. However, I think we can wait for others' input to see what they think about. My concern is:

What happens if we decide not to use the alpha/beta feature and want to delete it? If we decide not to promote feature A or B. How hard will it be if not all related code is not under the feature flag condition? But others might think that is OK

@perdasilva @tmshort WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

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

Similarly to my comment above about moving the feature flag checks to main, should we refactor this in a way that make the cache configurable as to the different layer media types and how they are handled?

Copy link
Contributor

Choose a reason for hiding this comment

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

actually - the comment is below =P

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Learning moment for me here. How have we removed feature gated code that we have decided not to land in the past? Is using the git history to undo code that is associated with a feature gate sufficient or acceptable?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it’d be helpful to keep all changes behind the feature gate clearly wrapped and centralized. That way, it’s easy to track what’s gated just by reading the code—since we’ll likely be iterating over multiple PRs, relying on Git history isn’t ideal.

Totally open to any approach that makes the boundary clear. The primary goal is to maintain cohesion and ensure we all share a common understanding of what lies behind the gate. 😊

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Understood. With that being said, from my perspective our options might be:

  1. Execute tests with feature gates enabled
  2. Extend the cache to allow tests to run even when the feature gate is disabled
  3. Don't wrap the Helm logic in the cache Store() method which will allow tests to run even with feature gate disabled

Open to hear any other ideas or if we might have a preference for one of these options over others.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@camilamacedo86 I was able to get a way to wrap the code and allow tests to run without issue. Hopefully that could suffice for now as we deliberate if to land the feature or not.

if features.OperatorControllerFeatureGate.Enabled(features.HelmChartSupport) || testing.Testing() {
if err := storeChartLayer(dest, layer); err != nil {
return err
}
}

"github.com/operator-framework/operator-controller/internal/operator-controller/rukpak/bundle/source"
"github.com/operator-framework/operator-controller/internal/operator-controller/rukpak/preflights/crdupgradesafety"
"github.com/operator-framework/operator-controller/internal/operator-controller/rukpak/util"
imageutil "github.com/operator-framework/operator-controller/internal/shared/util/image"
Copy link
Contributor

@camilamacedo86 camilamacedo86 Jun 12, 2025

Choose a reason for hiding this comment

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

@OchiengEd

Here: https://github.com/operator-framework/operator-controller/pull/1724/files

@perdasilva added a demo and the doc under the docs/draft for another alpha feature
It would be very nice if we could do your demo within and add the doc for that. Such as it was done in this PR. However, I am okay with it being a follow-up.

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 would be for adding documentation and a demo as a follow up.

@OchiengEd OchiengEd force-pushed the helm_explorations branch 2 times, most recently from 735a6d9 to 036e4c8 Compare June 12, 2025 21:26
@OchiengEd OchiengEd force-pushed the helm_explorations branch from 036e4c8 to 0dfea34 Compare June 13, 2025 01:26
@@ -209,6 +211,17 @@ func (h *Helm) buildHelmChart(bundleFS fs.FS, ext *ocv1.ClusterExtension) (*char
if err != nil {
return nil, err
}
if features.OperatorControllerFeatureGate.Enabled(features.HelmChartSupport) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We've been trying to put the feature checks in main. Wdyt about refactoring to have another implementation of the BundleToHelmChart converter that accepts chart bundles, or maybe that can route between different bundle types? Then if the feature gate is enabled, use that one?

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 do not have any concerns with having feature checks in main. I think that would be the ideal scenario as it would allow for feature-gated functionality to be tested at build time.

Trying to look at the issue from afar, our challenge in this case is we are trying to run tests on a feature gated function, pullChart() while we are not allowing a portion of the code in the cache's Store() method not to run since the feature gate is not enabled. The big question therefore is how do we navigate this quandary?

Copy link
Contributor

Choose a reason for hiding this comment

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

I do not have any concerns with having feature checks in main. I think that would be the ideal scenario as it would allow for feature-gated functionality to be tested at build time.

We are working towards to it
See; #1980

We will use the experimental CRD and have all feature flags enabled for our e2e tests.

@OchiengEd OchiengEd force-pushed the helm_explorations branch 2 times, most recently from fb98756 to 78069c9 Compare June 17, 2025 21:06
Comment on lines 136 to 147
if layer.MediaType == registry.ChartLayerMediaType {
if features.OperatorControllerFeatureGate.Enabled(features.HelmChartSupport) || testing.Testing() {
if err := storeChartLayer(dest, layer); err != nil {
return err
}
}
} else {
if _, err := archive.Apply(ctx, dest, layer.Reader, applyOpts...); err != nil {
return fmt.Errorf("error applying layer[%d]: %w", layer.Index, err)
}
Copy link
Member

Choose a reason for hiding this comment

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

I may have mentioned this elsewhere. If I did, apologies for repeating myself...

I feel like a better way of handling this would be to register handlers for media types. Then this section of the code would lookup the media type of the layer and then call whatever handler is found (or error if there isn't one).

With that setup, the registration of the helm chart media type/handler would be feature gated, but this code would not.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Code has been refactored. Hopefully I got your suggestion right.

* added support for deploying OCI helm charts which sits behind
the HelmChartSupport feature gate
* extend the Cache Store() method to allow storing of Helm charts
* inspect chart archive contents
* added MediaType to the LayerData struct

Signed-off-by: Edmund Ochieng <ochienged@gmail.com>
@OchiengEd OchiengEd force-pushed the helm_explorations branch from 742cb8a to 46af89e Compare June 25, 2025 17:38
Copy link
Contributor

@camilamacedo86 camilamacedo86 left a comment

Choose a reason for hiding this comment

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

Thank you a lot for your contribution 🥇
I’m OK with the changes 👍 Well done 🎉
/lgtm

IHMO: It is an initial implementation, and as follow-up, I think we need to do:

  • Documentation (docs/draft) and a demo automated for this one
  • A discussion around the remaining caveats, particularly how we plan to store the Helm chart bundle in the catalog via OPM

Would be great to get a PTAL from or at least one of them @joelanford, @thetechnick, and @perdasilva before get this one merged.

Thank you 🙌

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jun 25, 2025
@camilamacedo86
Copy link
Contributor

Hi @OchiengEd,

Just to clarify:

In the F2F, we talked about using a single internal type and converting everything to it. We also discussed having only one runtime—Buxcutter. PoC: #1946

Supporting Helm fully will take time, and it is a big journey as we have been discussing. There are still open questions and blockers. If we go with this approach (internal format), we probably want OPM/OLM to support the internal type first before anything else. I created an internal Slack channel so that we can discuss all details and caveats.

I’m OK merging this since it’s behind a feature gate—safe to experiment and doesn’t break anything. But it may change later.

PS: If we get it merged, it would be great to have a small doc with automated demo steps (as done for others feature gates), so people can understand what was done and iterate

Leaving final call to @joelanford, @thetechnick, and @perdasilva. 🔨

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants