-
Notifications
You must be signed in to change notification settings - Fork 66
🌱 Add internal direct bundle install support #2252
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
base: main
Are you sure you want to change the base?
🌱 Add internal direct bundle install support #2252
Conversation
✅ Deploy Preview for olmv1 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
53d52c9
to
15594cc
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #2252 +/- ##
==========================================
- Coverage 72.73% 72.32% -0.41%
==========================================
Files 89 90 +1
Lines 8747 8800 +53
==========================================
+ Hits 6362 6365 +3
- Misses 1968 2016 +48
- Partials 417 419 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
15594cc
to
fb36b11
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 For now it seems reasonable
/lgtm
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: camilamacedo86 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 |
cmd/operator-controller/main.go
Outdated
} | ||
|
||
packageName := path.Base(ref.Name()) | ||
bundleVersion := bsemver.MustParse(ext.Annotations[directBundleInstallVersionAnnotation]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't require or trust user input for the bundle version. Maybe fine for internal use, but in a user-facing feature, I think we'll have to dereference the version from the bundle image.
For now, perhaps leave a comment here to that effect?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem is that the version is embedded all the way down in the CSV. I.e. we'd need to pull the image and unpack it to figure out what it is. There's no guarantee that, e.g., the tag will be a valid semver. But, I agree. The ideal user-facing version of this would be to update the API, add a new source type, and just take the bundle image as input. I'll add the comment though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe the solution to this is something like: the resolver always returns an image reference, sometimes returns package and version information. After unpack, if we got nothing from the resolver, we just use what the bundle says, if we got something from the resolver we compare notes and error if there's a mismatch.
cmd/operator-controller/main.go
Outdated
}, | ||
} | ||
|
||
var resolver resolve.Func = func(ctx context.Context, ext *ocv1.ClusterExtension, installedBundle *ocv1.BundleMetadata) (*declcfg.Bundle, *bsemver.Version, *declcfg.Deprecation, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It feels a bit messy for this to live in main.go
. Maybe we should go ahead and make a composite resolver in the resolve package that can switch between the implementations?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand this isn’t the final solution — it’s more like one of the many intermediate steps to achieve the goal. So I’d be fine with handling it in a follow-up.
That said, it’s a really good point. 👍 +1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah - the idea was to be quick and dirty. But fair call. Tomorrow I'll massage it in to something more tenable.
fb36b11
to
28f3498
Compare
New changes are detected. LGTM label has been removed. |
fc7a5a6
to
e85efd0
Compare
Signed-off-by: Per Goncalves da Silva <pegoncal@redhat.com>
e85efd0
to
2c0d54a
Compare
// TODO: This is a temporary workaround to get the bundle from the filesystem | ||
// until the operator-registry library is updated to support reading from a | ||
// fs.FS. This will be removed once the library is updated. | ||
bundlePath, err := getDirFSPath(bundleFS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really don't like the FS interface, as it's so limiting, and you're already needing to reflect it to get the proper path. I'd almost prefer to get rid of the FS interface, and simply use a path string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(This is really just me whining about the FS interface is all... not asking for a change unless you agree and really want to.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't disagree. But, atm, this FG is just an artifice to help us play around with the boxcutter status without having to deal with catalogs. Ultimately, I'd probably suggest moving away from FS and towards a formalized bundle interface that can surface all this kind of information without too many headaches
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it would great to add at least some unit tests and great if we can have an e2e test demonstrating the usage.
) | ||
|
||
const ( | ||
directBundleInstallImageAnnotation = "olm.operatorframework.io/bundle-image" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we want to reflect in the annotation name that it is alpha feature, so something like:
alpha.olm.operatorframework.io/bundle-image-ref
// fs.FS. This will be removed once the library is updated. | ||
bundlePath, err := getDirFSPath(bundleFS) | ||
if err != nil { | ||
panic(fmt.Errorf("expected to be able to recover bundle path from bundleFS: %v", err)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why panic instead of
return nil, nil, nil, fmt.Errorf("expected to be able to recover bundle path from bundleFS: %v", err)
return nil, nil, nil, err | ||
} | ||
if len(fbc.Bundles) != 1 { | ||
return nil, nil, nil, errors.New("expected exactly one bundle") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perhaps you can provide in the error message the number of bundles we got?
bundle.Image = canonicalRef.String() | ||
v, err := bundleutil.GetVersion(bundle) | ||
if err != nil { | ||
return nil, nil, nil, err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you provide the error context here?
if ext.Annotations == nil || ext.Annotations[directBundleInstallImageAnnotation] == "" { | ||
return nil, nil, nil, fmt.Errorf("ClusterExtension is missing required annotation %s", directBundleInstallImageAnnotation) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check is performed even in MultiResolver, before invoking BundleResolver. Hence, we can drop it here.
directBundleInstallImageAnnotation = "olm.operatorframework.io/bundle-image" | ||
) | ||
|
||
type BundleResolver struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about to name it BundleImageRefResolver
? IMHO, BundleResolver
is too generic.
100% - the idea here though was to have something quick and dirty to aid us in playing around with the status stuff without having to deal with catalogs. There will definitely need to be tests of all kinds before this ever becomes user facing. Right now it shouldn't be on the critical path of other PRs. If it breaks, that's ok. |
Description
Adds annotation driven internal bundle install for internal purposes (at least for now) to aid in the testing / validation of extension and revision status development
P.S. this is not meant for user consumption (at least not yet) and I'm avoiding making API changes to not pollute the downstream techpreview API and possibly creating confusion
Reviewer Checklist