-
Couldn't load subscription status.
- Fork 68
[resolution pt.1] bundle entity #95
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
Conversation
149e01a to
fa0e642
Compare
Signed-off-by: perdasilva <perdasilva@redhat.com>
Signed-off-by: perdasilva <perdasilva@redhat.com>
Signed-off-by: perdasilva <perdasilva@redhat.com>
9017ba0 to
a55a00f
Compare
| } | ||
|
|
||
| func (b *BundleEntity) loadPackage() error { | ||
| if b.bundlePackage == nil { |
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 there no mutex lock required here unlike the other loadX funcs?
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.
Thank you!! Fixed
| if b.semVersion == nil { | ||
| semVer, err := semver.Parse(b.bundlePackage.Version) | ||
| if err != nil { | ||
| return fmt.Errorf("could not parse semver (%s) for entity '%s': %s", b.bundlePackage.Version, b.ID, 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.
Nit: use %w when wrapping errors in fmt.Errorf().
Here and below.
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.
Good call! Fixed =D
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.
In case anyone is wondering why you should use %w when wrapping errors in fmt.Errorf(), checkout this blog.
| if errComp != 0 { | ||
| // the sign gets inverted because version is sorted | ||
| // from highest to lowest | ||
| return -1 * errComp |
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.
So, this will put all non-valid versions at the end?
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.
Does this case get tested?
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 does, but your comment compelled me to 1) make sure 2) improve it =D
| func (b *BundleEntity) loadProvidedGVKs() error { | ||
| b.mu.Lock() | ||
| defer b.mu.Unlock() | ||
| if b.providedGVKs == nil { |
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 it possible for these values to become out-of-date? If so, if the value in the map was ever updated, this would continue to return the old value right?
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.
Great observation and question!!
This is read only and just serves to wrap around the Entity, which it doesn't expect to change during its lifetime.
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.
which it doesn't expect to change during its lifetime.
We may want to document any assumptions that we make. Do we prevent cache changes when deppy is solving?
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 == BundleEntity. The corresponding entity can change, but only on the source of truth (e.g. catalog source). But from the time you pull the entity down from source until resolution, it shouldn't change.
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.
Thanks for answering! Makes perfect sense to me.
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.
No blocking issues for me, just a couple questions 😃
a55a00f to
b4557d6
Compare
|
Getting failures now. |
Signed-off-by: perdasilva <perdasilva@redhat.com>
b4557d6 to
b0ecaf3
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.
/lgtm
|
You will need to rebase your other PRs. |
| bundleEntity := olmentity.NewBundleEntity(entity) | ||
| name, err := bundleEntity.PackageName() | ||
| if err != nil { | ||
| return false |
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.
Non-blocking nit: should we add debug logs to these messages?
| }) | ||
|
|
||
| Describe("InChannel", func() { | ||
| It("should return true when the entity has the has version in the right range", func() { |
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.
Non-blocking nit, but something we should fix.
| It("should return true when the entity has the has version in the right range", func() { | |
| It("should return true when the entity comes from the specified channel", func() { |
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.
Looks great Per, I appreciate all the test cases that you wrote!
This PR is the first in a series of PRs that bring bundle resolution to the operator-controller.
This PR adds:
BundleEntitystruct that makes it easier to deal with the deppy entities we'll be processingPredicatesto search for particular entities based on the bundle propertiesSortfunctions to order the entities based on their bundle properties (Note: default channel is not yet handled properly)