-
Notifications
You must be signed in to change notification settings - Fork 546
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
feat(catalog): multiple CatalogSource resolution #386
feat(catalog): multiple CatalogSource resolution #386
Conversation
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.
Some small things, but looks great overall!
sourcesSnapshot[key] = source | ||
} | ||
o.sourcesLock.RUnlock() | ||
sourcesSnapshot := o.getSourcesSnapshot() |
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.
👍
steps, notFoundErr = o.dependencyResolver.ResolveInstallPlan(sourcesSnapshot, srcKey, CatalogLabel, plan) | ||
if notFoundErr != nil { | ||
continue | ||
// Get the first key (arbitrary) |
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 have a followup issue/story to pass the desired catalog through to here?
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.
Not that I can see. Could we have a discussion on what the criteria of a desired first catalog is?
} | ||
var table = []struct { | ||
description string | ||
planCSVName 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.
doesn't seem like you need the planCSVName
field for anything (can be constant or generated per test) so may as well remove it here
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.
planCSVName specifies the main CSV the InstallPlan must resolve for each test in the test table. If we remove and hard-code we lose some flexibility with the naming of that CSV. (I'm wondering if it's worth taking out)
csvs map[string]csvName | ||
crds map[string]crdName | ||
srcKeys []registry.SourceKey | ||
expectedErr 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.
Instead of building the expected steps from the input csvs/crds, let's just have a list of expected steps (can include secrets then, too)?
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.
Got it.
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 good, just would be nice to add namespace
to status.catalogSources
list as well.
Name string `json:"name"` | ||
Manifest string `json:"manifest,omitempty"` | ||
CatalogSource string `json:"sourceName"` | ||
CatalogSourceNamespace string `json:"sourceNamespace"` |
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 we change status.catalogSources
to be a list with both the name
and namespace
of the CatalogSources
as well?
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.
InstallPlanStatus.CatalogSources
as a []registry.SourceKey
?
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.
Done.
f899556
to
7a0765a
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.
Limit number of CatalogSources
that we resolve from.
|
||
if err == nil { | ||
srm.Combine(csvSRM) | ||
usedSourceKeys = append(used, usedSourceKeys...) | ||
continue | ||
} | ||
|
||
// Attempt to resolve from any other CatalogSource | ||
for srcKey := range sources { |
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.
Only resolve from CatalogSources
in the same namespace of the InstallPlan
or the "global" namespace (o.namespace
).
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 reduced the catalog sources snapshot that gets passed in to only contain sources from plan.Namespace
and o.namespace
. That should address this issue.
// Copy the sources for resolution | ||
sourcesSnapshot := o.getSourcesSnapshot() | ||
// Copy the sources for resolution from the included namespaces | ||
includedNamespaces := map[string]bool{ |
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.
typically do map[string]struct{}
to avoid allocating the bool
|
||
var preferredSourceKey registry.SourceKey | ||
|
||
func (o *Operator) getPreferredSourceKey(plan *v1alpha1.InstallPlan, includedNamespaces map[string]bool) registry.SourceKey { |
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 this method makes more sense if it takes sourcesSnapshot
as an arg instead of included namespaces, since you've already filtered the sources by includedNamespaces above
var preferredSourceKey registry.SourceKey | ||
|
||
// Attempt to get the plan's source | ||
if _, ok := includedNamespaces[plan.Spec.CatalogSource]; ok { |
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 part wouldn't be needed if the source list were passed in, but as it is now I think it's supposed to be plan.Spec.CatalogSourceNamespace
@@ -215,24 +220,24 @@ func (resolver *MultiSourceResolver) resolveCSV(sources map[registry.SourceKey]r | |||
} | |||
|
|||
// registry.SourceKey for the source containing the CSV | |||
csvSrcKey := firstSrcKey | |||
csvSourceKey := preferredSourceKey |
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.
var csvSourceKey SourceKey
(easier to catch bugs where this isn't being set properly if it's not initialized to a valid value)
// Attempt to get the first source | ||
source, ok := sources[firstSrcKey] | ||
// Attempt to get the preferredSource | ||
source, ok := sources[preferredSourceKey] |
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.
There's a ton of code scattered throughout for managing the "preferred source". Ideally, these methods should not have to care about which source is preferred. This isn't something we have to fix now, it can be a followup or it can wait until we have better plans for a total-ordering of sources.
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 could always change the ResolveInstallPlan sources parameter to be a pre-ordered, pre-filtered slice of Sources. Another possible alternative is that we establish some criteria for general Source priority and pass in a priority queue.
…n owning subscription
…n newer kubeadm versions)
… a source snapshot
577741b
to
edb8cff
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 pending CI
…solution feat(catalog): multiple CatalogSource resolution
…solution feat(catalog): multiple CatalogSource resolution
Description
Adds multi-catalog resolution of CSVs and CRDs.
Addresses ALM-641