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

Fixes replace based upgrades #326

Merged
merged 1 commit into from
Aug 10, 2023
Merged

Conversation

m1kola
Copy link
Member

@m1kola m1kola commented Aug 8, 2023

Description

Fixes replace based upgrades.

Closes #321

Reviewer Checklist

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

@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 8, 2023
@codecov
Copy link

codecov bot commented Aug 8, 2023

Codecov Report

Merging #326 (66c6ae9) into main (dea70eb) will increase coverage by 20.26%.
The diff coverage is 100.00%.

@@             Coverage Diff             @@
##             main     #326       +/-   ##
===========================================
+ Coverage   62.58%   82.84%   +20.26%     
===========================================
  Files          21       21               
  Lines         890      892        +2     
===========================================
+ Hits          557      739      +182     
+ Misses        241      107      -134     
+ Partials       92       46       -46     
Flag Coverage Δ
e2e 62.66% <83.33%> (+0.08%) ⬆️
unit 78.59% <100.00%> (?)

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

Files Changed Coverage Δ
internal/resolution/entities/bundle_entity.go 98.30% <100.00%> (+41.52%) ⬆️
...nternal/resolution/entitysources/catalogdsource.go 61.42% <100.00%> (+1.72%) ⬆️
internal/resolution/util/predicates/predicates.go 95.00% <100.00%> (+55.00%) ⬆️
internal/resolution/variables/installed_package.go 100.00% <100.00%> (ø)
...al/resolution/variablesources/installed_package.go 71.42% <100.00%> (+9.35%) ⬆️

... and 9 files with indirect coverage changes

replacesValue, _ := json.Marshal(replacesProperty{Replaces: b.Replaces})
props["olm.replaces"] = string(replacesValue)
replacesValue, _ := json.Marshal(replacesProperty{
Replaces: fmt.Sprintf("%s-%s%s%s", bundle.Spec.Catalog.Name, b.Replaces, bundle.Spec.Package, ch.Name),
Copy link
Member Author

Choose a reason for hiding this comment

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

So the idea is that: in the entity properties we have formated replaces (vs raw data from catalogd objects) and don't have to format it in internal/resolution/variablesources/installed_package.go: we just filter entity source by id of the currently installed entity.

However I'm not entirely sure whether this is what we want to do. This limits replaces to a specific catalog and channel.

Copy link
Member

Choose a reason for hiding this comment

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

In OLM V0, which I believe is be the primary usecase for replace/skips/skipRange based upgrades, we supported cross channel updates. I suspect that we'll want to support cross channel upgrades here as well.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, and for semver upgrade support we also want:

  • The bundle resolved for an operator during an upgrade can come from a different channel or catalog than the currently installed bundle. (i.e. successors can come from any channel and any catalog)
  • The bundle resolved for an operator during an upgrade cannot come from a different package than the currently installed bundle.

So I'm looking into other options to solve this.

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 may be less restricting to have channel information be a new constraint rather than included into the replaces field keeping cross channel updates in mind, similar to what the upgrade support brief mentions.

Copy link
Member Author

Choose a reason for hiding this comment

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

@ankitathomas for now I'm trying to make minimal changes to fix it. I think this stuff will change a lot soon with semver based upgrades: #326 (comment)

@@ -140,7 +138,7 @@ func (b *BundleEntity) loadReplaces() error {
b.mu.Lock()
defer b.mu.Unlock()
if b.replaces == nil {
replaces, err := loadFromEntity[Replaces](b.Entity, "olm.replaces", optional)
replaces, err := loadFromEntity[Replaces](b.Entity, PropertyBundleReplaces, optional)
Copy link
Contributor

Choose a reason for hiding this comment

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

thank you!

@m1kola
Copy link
Member Author

m1kola commented Aug 9, 2023

Ok, here what I did:

  • I added a new property into CatalogdEntitySource: which contains a name of the current bundle and (if present in catalog) name of the bundle it replaces. Currently in the main we only have replaces and no current bundle name.
  • Updated InstalledPackageVariableSource and Replaces predicate to use the new prop
  • Updated a bunch of tests (mostly Entity mocks to include new prop)

For now I'm trying to make minimal changes to fix the issue, but I have a feeling that things will change internall once we introduce semver based upgrades.

@m1kola m1kola marked this pull request as ready for review August 9, 2023 15:51
@m1kola m1kola requested a review from a team as a code owner August 9, 2023 15:51
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 9, 2023
Copy link
Contributor

@perdasilva perdasilva left a comment

Choose a reason for hiding this comment

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

lgtm - thanks for this!! We're having some discussions around channels atm, so it could change, but getting this stable rn is super important!

Signed-off-by: Mikalai Radchuk <mradchuk@redhat.com>
@m1kola m1kola merged commit 28da6bd into operator-framework:main Aug 10, 2023
10 checks passed
@m1kola m1kola deleted the fixes_upgrades branch August 10, 2023 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants