Skip to content

✨ Filter out bundle versions lower than installed - #711

Merged
dtfranz merged 1 commit into
operator-framework:mainfrom
dtfranz:improve-resolution
Apr 9, 2024
Merged

✨ Filter out bundle versions lower than installed#711
dtfranz merged 1 commit into
operator-framework:mainfrom
dtfranz:improve-resolution

Conversation

@dtfranz

@dtfranzdtfranz commented Mar 22, 2024

Copy link
Copy Markdown
Contributor

Description

Adds an annotation to the App created for each extension indicating the bundle version, which can then be used on future reconciles to filter out older versions. This can be overridden by setting the Extension's UpgradeConstraintPolicy to Ignore.

Closes#654

This PR borrows a lot of stuff from @varshaprasad96 's PR #690 so I've added her as co-author :)

Reviewer Checklist

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

@dtfranz
dtfranz requested a review from a team as a code ownerMarch 22, 2024 14:57
@netlify

netlifyBot commented Mar 22, 2024

Copy link
Copy Markdown

Deploy Preview for olmv1 ready!

NameLink
🔨 Latest commit92ad69a
🔍 Latest deploy loghttps://app.netlify.com/sites/olmv1/deploys/66142666b94a0e0008ec8a93
😎 Deploy Previewhttps://deploy-preview-711--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 site configuration.

@dtfranz
dtfranzforce-pushed the improve-resolution branch from b4301b5 to 156420eCompareMarch 22, 2024 15:28
@codecov

codecovBot commented Mar 22, 2024

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 55.31915% with 21 lines in your changes are missing coverage. Please review.

Project coverage is 68.15%. Comparing base (8127270) to head (92ad69a).
Report is 6 commits behind head on main.

FilesPatch %Lines
internal/controllers/extension_controller.go46.15%18 Missing and 3 partials ⚠️
Additional details and impacted files
@@ Coverage Diff @@## main #711 +/- ##
==========================================
+ Coverage 63.50% 68.15% +4.65% 
==========================================
Files 22 22 Lines 1403 1429 +26 ==========================================
+ Hits 891 974 +83 + Misses 459 390 -69 - Partials 53 65 +12 
FlagCoverage Δ
e2e46.18% <0.00%> (-1.07%)⬇️
unit62.23% <55.31%> (+4.83%)⬆️

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.

Comment threadinternal/controllers/extension_controller.go
Comment threadinternal/controllers/extension_controller.go Outdated
@dtfranz
dtfranzforce-pushed the improve-resolution branch 2 times, most recently from 5e80cd5 to 05db735CompareMarch 22, 2024 16:15
}
}

func HigherBundleVersion(currentVersion *bsemver.Version) Predicate[catalogmetadata.Bundle] {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is a good start, but the end state needs to be the same as the current behavior of the ClusterExtension, which is one of:

  1. Semver semantics (if the "force semver" feature gate is enabled)
  2. Replaces, skips, skipRange semantics (which finds other bundles that have skips, replaces, skipRange that include the currently installed bundle)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Actually, I'm not sure ClusterExtension handles skips and skipRange for the second case. But it needs to there too.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

@joelanford Coming back to this after a v0 distraction and had a follow-up question here: for the second case, are we looking for bundles that do all three (replaces and skips and skipRange) or any one of the three?

@joelanfordjoelanfordApr 4, 2024

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Any, and then of all the matches, choose the one with the highest semver.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Thanks @joelanford ! I was just about finished adding the feature gating and replaces/skips/skipsRange then realized it was going to make the PR significantly larger (mostly due to tests). How do you feel about me doing that as a follow-up?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

+1 on wrapping this and capturing a follow-up issue.

I've implemented this for ClusterExtension here: #743

Given the recent change roadmap updates, I think we should try to wrap up work on Extension API for now, and capture a "current state of the world" of the Extension API and behavior.

Comment threadcmd/manager/main.go
Comment on lines -168 to -188
func hasKappApis(config *rest.Config) (bool, error) {
discoveryClient, err := discovery.NewDiscoveryClientForConfig(config)
if err != nil {
return false, fmt.Errorf("creating discovery client: %v", err)
}
apiResourceList, err := discoveryClient.ServerResourcesForGroupVersion(carvelv1alpha1.SchemeGroupVersion.String())
if err != nil && !errors.IsNotFound(err) {
return false, fmt.Errorf("listing resource APIs: %v", err)
}

if apiResourceList == nil {
return false, nil
}

for _, resource := range apiResourceList.APIResources {
if resource.Kind == "App" {
return true, nil
}
}
return false, nil
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

This change was taken from #690 , in which Varsha explained that the check is not needed due to the feature gate.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

So, why is it in yours? 😕

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

That PR is undergoing a refactor to combine the tests into a test loop, which is likely going to take some time given its relative priority. This particular change is valuable though since it made doing these tests much easier.

@openshift-merge-robotopenshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 29, 2024
@dtfranz
dtfranzforce-pushed the improve-resolution branch from 05db735 to aec5d08CompareApril 4, 2024 00:32
@openshift-merge-robotopenshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 4, 2024
if currentVersion == nil {
return false
}
bundleVersion, err := bundle.Version()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Not for this PR, just a though. I wonder if we should validate the bundle version on creation/ingress rather than on egress (i.e. bundle.Version() shouldn't return an error). So, a bundle object is always validated and correct.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I've had this thought too. If it didn't break any assumptions, it would be nice to get something into the declcfg.Bundle type for this.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Yeah that makes great sense and also would make it a lot easier to grab.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'll create a discussion upstream - see what ppl think - or would a ticket suffice?

Properties: []property.Property{
{
Type: property.TypePackage,
Value: json.RawMessage(`{"packageName": "package1", "version": "1.0.0"}`),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Oh, I see. I guess we'd need some sort of factory is we want to validate on creation...

Comment threadinternal/catalogmetadata/filter/bundle_predicates_test.go Outdated
Comment threadinternal/controllers/extension_controller.go Outdated
Comment threadinternal/controllers/extension_controller.go Outdated
Comment threadinternal/controllers/extension_controller_test.go Outdated
Comment threadinternal/controllers/extension_controller_test.go Outdated
Adds an annotation to the App created for each extension indicating the bundle version, which can then be used on future reconciles to filter out older versions. This can be overridden by setting the UpgradeConstraintPolicy to 'Ignore'.
Co-authored-by: Varsha Prasad Narsing <varshaprasad96@gmail.com>
Signed-off-by: dtfranz <dfranz@redhat.com>
@dtfranz
dtfranzforce-pushed the improve-resolution branch from aec5d08 to 92ad69aCompareApril 8, 2024 17:16
@dtfranz

Copy link
Copy Markdown
ContributorAuthor

Thank you for reviewing @perdasilva , I've updated per your comments. Please take another look when you can and let me know if you see anything else!

@perdasilvaperdasilva left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

chef's kiss! Thanks mate!!

@dtfranz
dtfranz added this pull request to the merge queue Apr 9, 2024
Merged via the queue into operator-framework:main with commit 49be998Apr 9, 2024
Sign up for freeto 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.

(Follow up): Integrate Kapp: Improve resolution logic in extension reconciler

5 participants

@dtfranz@joelanford@perdasilva@tmshort@openshift-merge-robot