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

feat(catalog): multiple CatalogSource resolution #386

Merged
merged 21 commits into from
Jul 24, 2018

Conversation

njhale
Copy link
Member

@njhale njhale commented Jul 18, 2018

Description

Adds multi-catalog resolution of CSVs and CRDs.

Addresses ALM-641

@njhale njhale requested review from ecordell and alecmerdler July 18, 2018 11:47
Copy link
Member

@ecordell ecordell left a 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()
Copy link
Member

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)
Copy link
Member

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?

Copy link
Member Author

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
Copy link
Member

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

Copy link
Member Author

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
Copy link
Member

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)?

Copy link
Member Author

@njhale njhale Jul 18, 2018

Choose a reason for hiding this comment

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

Got it.

Copy link
Member

@alecmerdler alecmerdler left a 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"`
Copy link
Member

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?

Copy link
Member Author

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?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

@njhale njhale force-pushed the multi-source-resolution branch from f899556 to 7a0765a Compare July 19, 2018 21:02
@njhale njhale changed the title Multi source resolution feat(catalog): multiple CatalogSource resolution Jul 20, 2018
Copy link
Member

@alecmerdler alecmerdler left a 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 {
Copy link
Member

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).

Copy link
Member Author

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{
Copy link
Member

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 {
Copy link
Member

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 {
Copy link
Member

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
Copy link
Member

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]
Copy link
Member

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.

Copy link
Member Author

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.

njhale added 21 commits July 24, 2018 13:20
@njhale njhale force-pushed the multi-source-resolution branch from 577741b to edb8cff Compare July 24, 2018 17:28
Copy link
Member

@ecordell ecordell left a comment

Choose a reason for hiding this comment

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

LGTM pending CI

@njhale njhale dismissed alecmerdler’s stale review July 24, 2018 21:54

Verbal agreement

@njhale njhale merged commit a7295d4 into operator-framework:master Jul 24, 2018
@njhale njhale deleted the multi-source-resolution branch July 27, 2018 15:16
njhale added a commit to njhale/operator-lifecycle-manager that referenced this pull request Sep 10, 2018
…solution

feat(catalog): multiple CatalogSource resolution
ecordell pushed a commit to ecordell/operator-lifecycle-manager that referenced this pull request Mar 8, 2019
…solution

feat(catalog): multiple CatalogSource resolution
Sign up for free to 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.

3 participants