-
Notifications
You must be signed in to change notification settings - Fork 54
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
Remove randomness in package uniqueness ordering #461
Merged
dtfranz
merged 1 commit into
operator-framework:main
from
m1kola:package_uniqueness_ordering
Oct 18, 2023
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 might be more straightforward to use
map[string]sets.Set[deppy.Identifier]{}
and simply append a sorted list from the set. That would give a defined order to the output, whereas now it seems to mirror the order of the variables in the input - is the order of the variables somehow useful or do we just need something deterministic?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.
Order of dependencies in bundle variable is important in some places. E.g. when we want to upgrade we sort dependencies in order of prefrence (which is just by versions at the moment).
I believe here specifically is not that important as we enforce uniqueness, but we still want to be deterministic so we can avoid doing this at some point.
It increase time complexity to O(n log n) and space will still be O(n) in both cases.
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.
You can remove
bundleIDs
andpackageOrder
variables. Regardless of the memory efficiency, it's just easier to read since there are fewer things in play.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 think going into log linear time is not worth the readability improvement.
Also It seems to me that we will still need:
Or am I missing something?
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 large is
n
? I imagine the change in runtime has no practical implication whatsoever.If you have:
I believe that would be sufficient, no? In any case, it's a small point and not worth belaboring.
Your transformation seems fine, but adding
bundleIDs
does make this slightly harder to follow, while allowing for new behavior - previously if a bundle ID existed for more than one package, it would be added to the list of both. Now there's a global uniqueness constraint. Is that intentional? Similarly, by trackingbundleOrder
separately (as opposed to extracting the keys ofpkgToBundles
) there's space for errors if the two are out of sync. If you don't think the duplication of the source of truth there and some of the new edges are worth worrying about, that's totally acceptable.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.
Just to verify, the current logic already ensures that packages and bundles are not duplicated in the resolver even if multiple catalogs provide the same information? For example, if I created a
Catalog
namedfoo
that had an image ref tosomeimage:foo
and aCatalog
namedbar
that had the exact same image ref ofsomeimage:foo
- what would happen in resolution if I asked to install a package that exists in thesomeimage:foo
catalog image?I'm definitely lacking domain knowledge regarding resolution, but I do think it is important to point out that catalogd doesn't perform any validation as to whether or not FBC content is repeated across multiple catalogs. As long as this is accounted for in resolution I think that should be fine 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.
OLMv1 (at least at the moment) allows the same package to come from multiple catalogs. If you have a package
foo
incatalog1
and incatalog2
it will treat them as the same package and I belive will allow upgrade of offoo
from version listed incatalog1
to version listed incatalog2
.However in this specific code we ensure that resolution only allows 1 bundle which belongs to pacakge
foo
. So even if you installcatalog1
andcatalog2
which is direct copy - we should be good.Did you mean that
someimage:foo
is the ref of the catalog image? If yes - we should be good as we only allow one bundle per pacakge in resolution.However I fear the case when there are pacakges
package1
andpackage2
which have bundles which share the same bundle image. I think this and this piece of code (they work together) might allow upgrading frompackage1
topackage2
and I think we don't want that.E.g. when catalogs (single catalog or two different catalogs) have something like this:
package1
bundles:image:tag1
- version1.0.0
package2
bundles:image:tag1
- version1.0.0
image:tag2
- version1.0.1
In this case, I think, when you install
package1
at version1.0.0
and then upgrade - our installed bundle might end up being the one frompackage2
since we search bundes by image references. And installed bundle is driving successors.I looked into how to mitigate this in #442, but it didn't feel like the right solutiion.
I want to get back to this.
P.S: Just noticed that we do not have an isue to track this - I'll create one shortly. Edit: created #466
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.
Is the bundle uniqueness based on the bundle image or the "name" of the bundle? would there be an issue if two separate packages specified a bundle with the same "name" but referenced different images?
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.
Late to the party. A couple of comments:
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.
Bundle image issue I mentioned above is the different part of the process (how we determine currently installed bundles for calculating possible successors). Sorry if I added confusion by mentioning unrelated thing: someone you wrote in the previous comment reminded me of this.
Here, where we create global uniqueness constraints for bundles, we are saying that "in our solution, bundle
foo
must have at most 1 bundle from the list of catalog-foo-bundlename.v1.0.0, catalog-foo-bundlename.v1.0.1, etc`. where things in the list are bundle variable IDs.This brings us to this:
It will not be an issue. For resolution we use variable IDs and they must be unique across whole cluster. When it comes to bundles - currently we construct variable ID based on catalog name, package name and bundle name:
operator-controller/internal/resolution/variables/bundle.go
Lines 63 to 67 in c9d387e
In OLMv0 (and until recently in OLMv1) we also had a channel as part of ID, but it is not necessary since we filter out unrelated bundles before we created a variable ID for them bundle and before we give them to the resolver.