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 0dfea34
🔍 Latest deploy log https://app.netlify.com/projects/olmv1/deploys/684b7e42f8a8a60008731fef
😎 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 73.33333% with 48 lines in your changes missing coverage. Please review.

Project coverage is 73.77%. Comparing base (1a27741) to head (0dfea34).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
internal/shared/util/image/helm.go 78.03% 20 Missing and 9 partials ⚠️
internal/operator-controller/applier/helm.go 0.00% 8 Missing and 1 partial ⚠️
internal/shared/util/image/cache.go 82.35% 4 Missing and 2 partials ⚠️
internal/shared/util/image/pull.go 20.00% 3 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1971      +/-   ##
==========================================
+ Coverage   69.28%   73.77%   +4.49%     
==========================================
  Files          79       81       +2     
  Lines        7051     7322     +271     
==========================================
+ Hits         4885     5402     +517     
+ Misses       1884     1584     -300     
- Partials      282      336      +54     
Flag Coverage Δ
e2e 43.04% <1.66%> (+0.09%) ⬆️
unit 60.48% <73.33%> (+0.29%) ⬆️

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
}

@OchiengEd OchiengEd force-pushed the helm_explorations branch 4 times, most recently from 4b69de7 to f33fe5c Compare June 4, 2025 20:26
@OchiengEd
Copy link
Contributor Author

OchiengEd commented Jun 10, 2025

Also added logic to inspect the contents of a .tgz or .tar.gz file to verify it contains of a Helm archive.

func inspectChart(data []byte, metadata *chart.Metadata) (chartInspectionResult, error) {
gzReader, err := gzip.NewReader(bytes.NewReader(data))
if err != nil {
return chartInspectionResult{}, err
}
defer gzReader.Close()
report := chartInspectionResult{}
tarReader := tar.NewReader(gzReader)
for {
header, err := tarReader.Next()
if err == io.EOF {
if !report.chartfileExists && !report.templatesExist {
return report, errors.New("neither Chart.yaml nor templates directory were found")
}
if !report.chartfileExists {
return report, errors.New("the Chart.yaml file was not found")
}
if !report.templatesExist {
return report, errors.New("templates directory not found")
}
return report, nil
}
if strings.HasSuffix(header.Name, filepath.Join("templates", filepath.Base(header.Name))) {
report.templatesExist = true
}
if filepath.Base(header.Name) == "Chart.yaml" {
report.chartfileExists = true
if err := loadMetadataArchive(tarReader, metadata); err != nil {
return report, err
}
}
}
}

@OchiengEd OchiengEd force-pushed the helm_explorations branch 2 times, most recently from 959072a to b569fb8 Compare June 11, 2025 15:49
@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 +142
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?

"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

var _ io.Reader = &dummyReader{}

func (r *dummyReader) Read(p []byte) (n int, err error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

@OchiengEd we have a lint issue here to sort out.

Copy link
Contributor

Choose a reason for hiding this comment

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

/home/runner/go/bin/golangci-lint-v1.64.6 run --build-tags containers_image_openpgp --out-format colored-line-number
Error: internal/shared/util/image/cache_test.go:808:1: named return "n" with type "int" found (nonamedreturns)
func (r *dummyReader) Read(p []byte) (n int, err error) {
^
make: *** [Makefile:122: lint] Error 1
Error: Process completed with exit code 2.

* 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 <[email protected]>
@OchiengEd OchiengEd force-pushed the helm_explorations branch from 036e4c8 to 0dfea34 Compare June 13, 2025 01:26
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

Successfully merging this pull request may close these issues.

5 participants